emprit

select

Jul 13th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. ###############select#################
  2.  
  3.     Class News
  4.     {
  5.             protected $table='kategori_news';
  6.             public function __construct(){
  7.                 //$this->news = $news;
  8.                    
  9.             }
  10.      
  11.             public  function kategori(){
  12.                             $records = array();
  13.                     $sql = "SELECT id_kategori, kategori from ".$this->table;
  14.                     $query = mysql_query($sql) or die(mysql_error());
  15.                     if($query){
  16.                             while ($result = mysql_fetch_array($query,1)) {
  17.                                     $records[] = $result;
  18.                             }
  19.                     }
  20.      
  21.                     return $records;
  22.             }
  23.     }
  24.  
  25. --------------------------------view---------------------------
  26. <select name='kategori'>
  27.     <?php      
  28.     foreach($query as $row){
  29.         echo "<option value='$row->id_kategori'>$row->kategori</option>";
  30.     }
  31.     ?>
  32. </select>
Advertisement
Add Comment
Please, Sign In to add comment