Jump to content

Need data from one row in DB


CincoPistolero

Recommended Posts

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

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>";
}

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'];

?>

Archived

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

×
×
  • Create New...

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.