Entry
I can only get the last record from a database to be displayed, how do I get all records to display?
Nov 27th, 2008 05:09
healthy man, dman, Fabian Mellegård, Andy Wright,
Here is how I do it. There are probarbly other way but ...
/Fabian
I have a table created like this:
CREATE TABLE doc_tab (doc_id INT NOT NULL DEFAULT '0' AUTO_INCREMENT,
docnr VARCHAR(9) NOT NULL,
PRIMARY KEY (doc_id),
UNIQUE doc_id (doc_id),
UNIQUE docnr (docnr));
To get all entrys displayed I simply write:
<?php
// Opens the database
$datab = mysql_connect("localhost");
mysql_select_db("doctest",$datab);
// query to get all the document numbers. Get the numbers in reversed
// order, i.e. last stored record first.
$query = "SELECT doc_id, docnr FROM doc_tab ORDER BY doc_id DESC";
$result = mysql_query($query, $datab) or die ("Could not execute
query: $query");
// Print all the records
while ($doc_data = mysql_fetch_row($result))
{
echo "document number: $doc_data[1] <br>";
}
?>
http://www.healthbyhealth.com
http://www.healthment.com
http://www.mesotheliomadown.com
http://www.mesotheliomaout.com
http://www.pickarticle.com