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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Sui
Forum Newbie
Posts: 2
Joined: Wed Nov 05, 2003 8:16 am
Contact:

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

Post 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
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Using the WHERE clause...

Code: Select all

$query = "SELECT info1, info2, info3 FROM 'tablename' where id = '1'";
Sui
Forum Newbie
Posts: 2
Joined: Wed Nov 05, 2003 8:16 am
Contact:

Post by Sui »

Cheers JAM.

Much appreciated
Post Reply