PHP/MySQL Database/mysql fetch row
mysql_fetch_row() fetches rows
Its syntax is: array mysql_fetch_row() (int result)
<?
@mysql_connect("localhost", "root","") or die("Could not connect to MySQL server!");
@mysql_select_db("mydatabase") or die("Could not select database!");
$query = "SELECT * FROM mytable";
$result = mysql_query($query);
print "<table>\n";
print "<tr>\n<th>ID</th><th>Title</th><th>MyValue</th>\n</tr>\n";
while (list($id, $title, $myvalue) = mysql_fetch_row($result)) :
print "<tr>\n";
print "<td>$id</td>\n<td>$title</td>\n<td>$myvalue</td>\n";
print "</tr>\n";
endwhile;
print "</table>";
mysql_close();
?>
mysql_fetch_row.php
<?
mysql_connect("localhost","root","");
mysql_select_db("mydatabase");
$query = "SELECT id, title FROM product ORDER BY title";
$result = mysql_query($query);
while (list($id, $title) = mysql_fetch_row($result))
{
echo "Product: $title ($id) <br />";
}
?>