![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
On Fri, 1 Sep 2006 18:27:00 -0500, Gary wrote: I've built a page in Dreamweaver (php) pulling records from mysql with rand() order, displaying 1 record at a time with a navigation pane, it correctly counts the number in the recordset, but when the user clicks on the navigation set to go to the next record, it sometimes repeats the records already shown. Is there a way to randomly sort a recordset, showing one record at a time, without repeating the ones shown? Are you pulling records from a randomly-ordered record set, or are you plucking the top record off of a fresh randomly-ordered record set every time the next record is called for? The two are very different ways of doing things, and the latter will occasionally show the pattern you describe, while the former won't, at the disadvantage of eventually running out of random records. Another alternative is to remember the record last viewed in the php code and simply rerun your pull again if you get the same one again. -- 55. The deformed mutants and odd-ball psychotics will have their place in my Legions of Terror. However before I send them out on important covert missions that require tact and subtlety, I will first see if there is anyone else equally qualified who would attract less attention. --Overlord |
#3
| |||
| |||
|
|
On Tue, 12 Sep 2006 18:46:02 -0500, Gary wrote: Only one record is being displayed at a time, but I think the page is being reloaded when the user clicks on the navigation bar ('NEXT') button, which would re-run the code to select a random record. Not sure how to do former suggestion without causing page to reload. The cheap way would be to make the NEXT button pass back (via either GET or POST) the unique id for the record currently being displayed, and have the query use a WHERE uniq_id <> '$old_uniq_id' in its selection criteria... You might still end up with a A C F E B E B D pattern, but that's probably *slightly* less obnoxious than a A C F F F F B D pattern... Of course, there's lots and lots of far more complicated ways of extending that into things like "exclude the last 5 records hit" or "exclude the last (10% of COUNT(*)) records", or endless other ways of making rand() even less random in ways that are happy. Once I cheated and made a new column that contained a "next_random" column and simply had a little program regenerate the linked list occasionally. "Peter H. Coffin" <hellsop (AT) ninehells (DOT) com> wrote in message news:slrneg0544.748.hellsop (AT) abyss (DOT) ninehells.com... On Fri, 1 Sep 2006 18:27:00 -0500, Gary wrote: I've built a page in Dreamweaver (php) pulling records from mysql with rand() order, displaying 1 record at a time with a navigation pane, it correctly counts the number in the recordset, but when the user clicks on the navigation set to go to the next record, it sometimes repeats the records already shown. Is there a way to randomly sort a recordset, showing one record at a time, without repeating the ones shown? Are you pulling records from a randomly-ordered record set, or are you plucking the top record off of a fresh randomly-ordered record set every time the next record is called for? The two are very different ways of doing things, and the latter will occasionally show the pattern you describe, while the former won't, at the disadvantage of eventually running out of random records. Another alternative is to remember the record last viewed in the php code and simply rerun your pull again if you get the same one again. -- 55. The deformed mutants and odd-ball psychotics will have their place in my Legions of Terror. However before I send them out on important covert missions that require tact and subtlety, I will first see if there is anyone else equally qualified who would attract less attention. --Overlord -- 100. Finally, to keep my subjects permanently locked in a mindless trance, I will provide each of them with free unlimited Internet access. --Peter Anspach's list of things to do as an Evil Overlord |
![]() |
| Thread Tools | |
| Display Modes | |
| |