For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Monday, February 16, 2015

Better way to fill select box in php

Problem:

Better way to fill select box in php

Solution:

Use Heredoc as below example

Example:

Assuming that $rs_list is the query result.
<?php
$list_trans="";
foreach ($rs_list->result() as $row_list) {
        $nm= $row_list->nm;
        $id=$row_list->id;
       
$list_trans.= <<<ABC
<option value="$id">$nm</option>
ABC;
    }
 ?>

    <select name="transporter_id">
            <?php echo $list_trans;?>
            </select>




Share:

0 comments:

Post a Comment

Add Dependent Scripts

   here is the code that allow to add dependent script :         <script>         const addDependentScripts = async function( scriptsT...

Ads Inside Post

Powered by Blogger.

Arsip