You are here: Grabing the 5 latest rows « PHP Programming Language « IT news, forums, messages
Grabing the 5 latest rows

Posted by Lenard Redwood on 12/13/06 13:16

I am trying to create a PHP script that queries entries from a MySQL
table:

<?php
$user="myusername";
$password="mypassword";
$database="mydatabase";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT ititle, inumber FROM nucleus_item";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Name :{$row['ititle']} <br>" .
"Subject : {$row['inumber']} <br>";
}
mysql_close();
?>

What I'd like to do is to grab the 5 latest rows of the "inumber"
field. This field starts from 1 and currently ends at 2100 but everyday
there are new entries. So I think I should sort the table rows from the
greatest number to the lowest, and take only the 5 latest entries. I
didn't find on php.net how to do that. Any idea?
Thanks,

Lenard.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация