Hello!
I am doing a project and developing a table using php and it is giving me an error as
"Warning: mysql_result() expects parameter 1 to be resource, object given in C:\xampp\"
please help to resolve this problem. Relevent code is given below
i dont know how to correct that warning it is not showing name and prices please help. thanks in advancePHP Code:<?php
$con=mysqli_connect("localhost","root","","onlinegourmet");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//$ID = mysql_insert_id();
$sql="SELECT pname, price FROM product WHERE category = 'Bakery'";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
$rs = mysqli_query($con,$sql);
$count = mysqli_num_rows(mysqli_query($con,$sql));
echo '<table border="1" width="100%">';
for($i=0; $i<$count; $i++){
$name = mysql_result($rs, $i, "pname") or die (mysql_error());
$price = mysql_result($rs, $i, "price") or die (mysql_error());
echo "<tr>";
echo "<td>";
echo "<input name='Bakery[]' type='checkbox' value='$name'/>";
echo "</td>";
echo "<td>";
echo "$name";
echo "</td>";
echo "<td>";
echo "$price";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>![]()



Reply With Quote


Bookmarks