Monday, May 6, 2019

PHP Database Class and it's use - Part 2

This is how you can use it for select.

 <?php  
   include_once('classes/class.database.php');  
   $db = new MySQLiDB;  
   $args = [  
     'table' => 'tblcity',  
     'data' => [  
       'idCity','lbCityName'  
     ],  
        'order' => 'lbCityName', // order by  
        'oType' => '' // ASC or DESC  
     ];  
   $fetch = $db->select($args);  
   $res;  
   ?>  

loading a dropdown list

 <select required="" id="pickup" name="pickup" class="form-control" >  
   <option>Please Select</option>  
   <?php   
    foreach ($fetch as $city)  
    {                                               
         ?>  
   <option value='<?php echo $city['idCity'];?>'> <?php echo htmlentities(utf8_encode($city['lbCityName'])); ?></option>  
   <?php  
    }  
    ?>     
 </select>  

I will discuss the insert on next post.

No comments:

Post a Comment