Jump to content


Photo

help! returning a single row on a database query


  • Please log in to reply
2 replies to this topic

#1 lee20

lee20
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 August 2003 - 03:30 AM

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

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 11 August 2003 - 03:34 AM

don\'t use the while...

$select = "SELECT * FROM `table Where value=\'$variable\'"; $query = mysql_query($select); $row = mysql_fetch_row($query);$var1= $row[0];

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 lee20

lee20
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 August 2003 - 03:36 AM

that easy huh? thx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users