Ok, all I wanna do is retrieve the entries from newest to oldest. Originally it retrieved from oldest to newest but that's not exactly what I'm wanting haha. The below code doesn't work, for no obvious reason I can find so please tell me where I steered wrong
That's in the head to retrieve the info and this is where it's output:mysql_connect('XXX',$dbuser,$dbpass);
@mysql_select_db($database) or die('Unable to select database');
$query="SELECT * FROM news";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
It outputs an error (I put it in the post, below) and then outputs the newest entry, but NOT the one before it (so the oldest). I'm sorry to waste time I'm sure it's a dumb error but even after multiple tutorials and Googles I can't find out what's wrong. I know someone here can point it out quick.while ($num > 0) {
$date = mysql_result($result,$num,"date");
$author = mysql_result($result,$num,"author");
$title = mysql_result($result,$num,"title");
$body = mysql_result($result,$num,"body");
echo $title,'<br>',$date,'<br>by: ',$author,'<br><br>',$body;
$num--;
}
Thanks alot,
Tim
edit:
edit 2: wait maybe I should take the number of rows I get and do 'WHERE id' is the num since it should match...is that my problem?Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 2 in /home/content/f/a/s/fassist/html/test/news/index.php on line 34




Reply With Quote


Bookmarks