Hi all,

The following code should select all data, grab the highest value row (i.e. the newest), and display that exact rows number, contained text and time/date of creation.

It is correctly grabbing the row number, but still only grabbing the contents of the first row.

I am not getting any errors at all, just the displayed data is incorrect

<?php 
$dbh=mysql_connect ("-", "-", "-") or die 
('I cannot connect to the database because: ' . mysql_error()); 
mysql_select_db ("silverlink"); 
$rs = mysql_query("SELECT max(post_id), post_text, post_create_time FROM forum_posts ") or die
(mysql_error());
while ( $rows = mysql_fetch_array( $rs) )
{
echo "<p>";
echo $rows['post_text'];
echo "</p>";
echo "<p>";
echo $rows['post_create_time'];
echo "</p>";
echo $rows[0];
}
?>

Recommended Answers

All 3 Replies

because u have applied max function thats why it will pic just max(post_id) if you want all the records from latest to old then ur query should be

"SELECT post_id, post_text, post_create_time FROM forum_posts order by post_id desc"

hi,

i only want it to show the (say 3) newest records

I have it, just ad LIMIT N to the end

thanks for your help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.