PHP/MySQL Database/mysql fetch row
mysql_fetch_row() fetches rows
<source lang="html4strict">
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 "ID | Title | MyValue | \n
---|---|---|
$id | \n$title | \n$myvalue | \n"; print "
mysql_close(); ?>
</source>
mysql_fetch_row.php
<source lang="html4strict">
<? 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)
"; }
?>
</source>