Re: Displaying results either side of an Query?
| From: | Daniel Convissor | Date: | Thu, 12 Oct 2000 17:05:13 +0000 |
| Subject: | Re: Displaying results either side of an Query? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19847@lists.php.net to get a copy of this message | ||
Hey Joseph:
> I got a bit of a tricky problem, I need to be able to find a result in a
> mysql table and then dispaly this result in the middle of a predefined
> number of results for example:
>
> 15 results
> *My Query*
> 15 results
But what do you want the 15 other, well 30 really, results to be? Is each
row of this table going to contain the same columns, just showing the data
from 15 randomly selected records before your choice and after your choice?
If you want random records, keep in mind the MySQL manual says "In MySQL
3.23, you can however do: SELECT * FROM table_name ORDER BY RAND()." That
may be helpful for you. You can even throw on a LIMIT 30.
If I'm understanding you correctly, I'd create two queries, one for the data
you want and another for the random data. Then, loop through the random data
in a for loop, when you hit your magic number, spit out your special record,
then resume with your random data.
Have fun,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
More than just answers. Solutions. (SM)
http://www.analysisandsolutions.com/
4015 7 Av #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409