lee20 Posted August 11, 2003 Share Posted August 11, 2003 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 Link to comment https://forums.phpfreaks.com/topic/867-help-returning-a-single-row-on-a-database-query/ Share on other sites More sharing options...
effigy Posted August 11, 2003 Share Posted August 11, 2003 don\'t use the while... $select = "SELECT * FROM `table Where value=\'$variable\'"; $query = mysql_query($select); $row = mysql_fetch_row($query); $var1= $row[0]; Link to comment https://forums.phpfreaks.com/topic/867-help-returning-a-single-row-on-a-database-query/#findComment-2886 Share on other sites More sharing options...
lee20 Posted August 11, 2003 Author Share Posted August 11, 2003 that easy huh? thx Link to comment https://forums.phpfreaks.com/topic/867-help-returning-a-single-row-on-a-database-query/#findComment-2887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.