You are here: Re: question about processing MySQL query result « PHP Programming Language « IT news, forums, messages
Re: question about processing MySQL query result

Posted by strawberry on 06/22/06 06:17

in the query itself you could add 'order by rand() limit 4'

vito wrote:
> after executing the query, say it returns 1000 results.
>
> if i just want to do some sampling and like to have a look on 4 of them,
> how can i refer to these 4 random records out of 1000? i'm working on
> processing the result of $res_array which has 1000 records.
>
> query = select * from test;
>
> result = mysql_query(query);
>
> records1000 = db_result_to_array($result);
> //how to select/remove records1000 to get say, records4?
>
>
> function db_result_to_array($result) {
> $res_array = array();
> for ($count=0; $row = $result->fetch_assoc(); $count++) {
> $res_array[$count] = $row;
> }
> return $res_array;
> }

 

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

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