[ale] recommend a good PHP/MYSQL list?
F. Grant Robertson
f.g.robertson at alexiongroup.com
Fri Apr 18 17:25:16 EDT 2003
You can still use the ORDER BY clause with a WHERE IN or a random select with a limit..
P.s.. you should really look into using mysql_fetch_array() and extract().. it would make your code much cleaner
-----Original Message-----
From: ale-admin at ale.org [mailto:ale-admin at ale.org]On Behalf Of
To: ale at ale.org
ChangingLINKS.com
Sent: Friday, April 18, 2003 5:06 PM
To: ale at ale.org
Subject: Re: [ale] recommend a good PHP/MYSQL list?
Nah. What I am trying to do is more complex. The closest thing I could find is
like a cross between a subselect and a sort:
/*
http://www.mysql.com/doc/en/ANSI_diff_Sub-selects.html
http://www.mysql.com/doc/en/Sorting_rows.html
*/
I want to select random records from the table AND list the result order by id
DESC;
Without throwing the data into an array (cause I really don't know how :)).
Something like this:
///
$sql="select value from table order by rand(), order by id desc limit 20";
$result=mysql_query($sql);
while ($myrow=mysql_fetch_array($result))
{
$value=$myrow["value"];
printf ("value");
///
(So take 20 random rows -of the 1000 that exist- AND order by id DESC)
I am thinking someone would suggest grabbing the random records and sorting
them in the while array somehow. But that is over my head (which is why I
turned to the mySQL queries). I couldn't find that concept in the manual.
Drew
On Fri April 18 2003 15:34, F. Grant Robertson wrote:
> Mysql can return random rows.. or you could generate psuedo random numbers
> and query by WHERE IN (1,2,3,4,5)
>
> Take a look at the mysql manual..
>
> http://www.mysql.com/doc/en/index.html
>
> -G
>
>
> -----Original Message-----
> From: ale-admin at ale.org [mailto:ale-admin at ale.org]On Behalf Of
> ChangingLINKS.com
> Sent: Friday, April 18, 2003 4:05 PM
> To: ale at ale.org
> Subject: [ale] recommend a good PHP/MYSQL list?
>
>
> That php-ale list hasn't materialized yet, and I am not thinking I should
> post lots of php questions (though it would be a positive offset to the
> flame battles that arise).
>
> Can someone recommend a great php list (from experience)?
>
> I am trying to grab random records from a mysql database and put them in
> order desc by primary key in one query.
--
Wishing you Happiness, Joy and Laughter,
Drew Brown
http://www.ChangingLINKS.com
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list