Reply to Re: Fetching

Your name:

Reply:


Posted by purcaholic on 05/22/07 08:31

On 22 Mai, 09:42, java.i...@gmail.com wrote:
> how to fetch the last five records in mysql through php

You can use mysql_data_seek to move the internal row pointer to the
desired position. After then using a mysql_fetch_*() function in a
while loop will iterate until the last position of the results.
Example:
[snip]
if (!$result = mysql_query('SELECT * WHERE 1=1')) {
die('Invalid query: ' . mysql_error());
}

if ($num_rows = mysql_num_rows($result)) {
mysql_data_seek($result, $num_rows-5);
while ($row = mysql_fetch_array($result)) {
$data[] = $row;
}
}
var_dump($data);
[/snap]

purcaholic

[Back to original 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

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