mysql - Retrive data from database and display in table using php -
i have 2 table named item , price. these fields , data of both table
table : item     item_id | item_name   1     | abc   2     | xyz,jkl,qwe  table : price       id    | item_price | item_id   1     | 50         |  1   2     | 60         |  2   3     | 100        |  1   where item_id reference of item table. need create table in php display data item table. item_name have multiple value seperated coma. need explode them , use drop-down(select) in table.my expected outputt given below.
item_id | item_name | item_price   note : item_name must have select option (dropdown)
use below query records database
select a.item,b.item_price table1 a,table2 b a.item_id=b.id;
and on front end(php), try below
$results=mysqli_query($db,"select a.item,b.item_price table1 a,table2 b a.item_id=b.id");   if(mysqi_num_rows($result) > 1 ) {    echo "<table><tr><th>item_id </th><th>item_name</th><th>item_price</th></tr></table>";   while($row=mysqli_fetch_array($result))   {      echo "<tr>";     echo "<td>".$row['item_id']."</td>";      $arry=explode(',',$row['item_name']);      echo "<td><select>";      foreach($arry $value)       {         echo "<option>".$value."</option>";        }       echo "</select></td>";      $array=array();    echo "<td>".$row['item_price']."</td></tr>";   }      echo "</table>";   }      
Comments
Post a Comment