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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip