Jump to content

Archived

This topic is now archived and is closed to further replies.

lee20

help! returning a single row on a database query

Recommended Posts

i\'m trying to query the database and only get one result. i\'ve always used while loops when i query the database, but i need to query for the first matching criteria and return that row.

 

$select = \"SELECT * FROM `table Where value=\'$variable\'\";

$query = mysql_query($select);

while($row = mysql_fetch_row($query))

{

//I want to return only the first row with the matching criteria.

$var1= $row[0];

etc..

}

 

Help! Thx

Share this post


Link to post
Share on other sites

don\'t use the while...

 

$select = "SELECT * FROM `table Where value=\'$variable\'"; 

$query = mysql_query($select); 

$row = mysql_fetch_row($query);

$var1= $row[0];

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.