Page 1 of 1

[SOLVED] extracting all info from an ID in a table

Posted: Wed Nov 05, 2003 8:16 am
by Sui
Hi guys, can anyone show me the query i need to include to extract info from a table in a database by using the ID in the table as the target.

I am used to getting info from this:

mysql_connect ("host", "database", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("database");


$query = "SELECT info1, info2, info3 FROM "tablename" ORDER BY id";

$tablename = mysql_query($query) or die ("Query failed");

while ($tablenames = mysql_fetch_array($tablename))

The info is pulled into a table on my site and lists every entry in the table, however, is there a way i can just pull out one entry by it's ID.

Please be gentle as I'm completely new

Posted: Wed Nov 05, 2003 8:32 am
by JAM
Using the WHERE clause...

Code: Select all

$query = "SELECT info1, info2, info3 FROM 'tablename' where id = '1'";

Posted: Wed Nov 05, 2003 8:59 am
by Sui
Cheers JAM.

Much appreciated