Hey i am getting Illegal string offset warning in php when i try to store the values from associate array into a table.
When i print the associate array i get this :
Array ( [productName] => iphone [productDesc] => A product from apple [price] => 5 [image] => test/Group/pic.png )
$db1 = new mysqli('localhost',$user,$pass,$db) or die (" Connection failed ");
$query="Select productName,productDesc,price,image from product where productID=1";
$query_first=mysqli_query($db1,$query) or die("Query not retrieved");
$query_second=mysqli_fetch_assoc($query_first);
//print_r($query_second);
$rows=mysqli_num_rows($query_first);
echo '<table border="1">';
echo '<tr>
<td> Product Name</td>
<td> Product Description</td>
<td> Price</td>
<td> Image </td>
</tr> ';
foreach($query_second as $r)
{
echo '<tr><td>'.$r['productName'];
echo '</td><td>'.$r['productDesc'];
echo '</td><td>'.$r['price'];
echo '</td><td>'.$r['image'];
echo '</td></tr>';
}//end foreach
echo"</table>";
mysqli_fetch_associn a while rather than aforeach