CincoPistolero Posted March 15, 2008 Share Posted March 15, 2008 I need to just pull data from one row in a table. Below is the code I use for the SQL. $query_au = "SELECT * FROM about WHERE active=1 ORDER BY aboutID"; $result_au = mysql_query($query_au) or die ("Error in query: $query_au. " . mysql_error()); $row = mysql_fetch_row($result_au); And here is how I try to display it. Unfortunately, it is not displaying anything. Any help is appreciated. <?php echo "$body"; ?> Link to comment https://forums.phpfreaks.com/topic/96246-need-data-from-one-row-in-db/ Share on other sites More sharing options...
peranha Posted March 15, 2008 Share Posted March 15, 2008 you need to do <?php echo $row['rowname']; ?> Link to comment https://forums.phpfreaks.com/topic/96246-need-data-from-one-row-in-db/#findComment-492681 Share on other sites More sharing options...
CincoPistolero Posted March 15, 2008 Author Share Posted March 15, 2008 I've tried that and its not working either. Is there an issue with my db call? Link to comment https://forums.phpfreaks.com/topic/96246-need-data-from-one-row-in-db/#findComment-492685 Share on other sites More sharing options...
peranha Posted March 15, 2008 Share Posted March 15, 2008 Here is my code, you can try it, it works on my site. I just put a while statement in there and if no results, it says there is none. while($row = mysql_fetch_row($result)) { ?> <?php echo $row[0];?> <?php } } else { // no // print status message echo "<b class=red>"; echo "No rows found!"; echo "</b>"; } Link to comment https://forums.phpfreaks.com/topic/96246-need-data-from-one-row-in-db/#findComment-492690 Share on other sites More sharing options...
phpSensei Posted March 15, 2008 Share Posted March 15, 2008 Forgot single quotes, and DESC or ASC for the Order By try <?php $query_au = "SELECT * FROM about WHERE `active` = '1' ORDER BY `aboutID` DESC"; $result_au = mysql_query($query_au) or die (mysql_error()); $row = mysql_fetch_assoc($result_au); echo $row['row_1']; ?> Link to comment https://forums.phpfreaks.com/topic/96246-need-data-from-one-row-in-db/#findComment-492697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.