Randomize List But only Show One Record
7 posts by 4 authors in: Forums > CMS Builder
Last Post: May 14, 2012 (RSS)
By Mohaukla - April 17, 2012
How would I show that?
list($did_you_knowRecords, $did_you_knowMetaData) = getRecords(array(
'tableName' => 'did_you_know',
));
And
<?php foreach ($did_you_knowRecords as $record): ?>
<?php echo $record['title'] ?><br/>
<?php echo $record['content'] ?>
<?php endforeach ?>
Thanks
Michael
Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.
"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"
Re: [justritedesign] Randomize List But only Show One Record
By (Deleted User) - April 17, 2012
If you're loading all the records from the table, you can randomly select a record from the array with array_rand:
$rand_key = array_rand($did_you_knowRecords, 1);
and then output the specific record like this:
<?php echo $did_you_knowRecords [$rand_key]['title'] ?><br/>
<?php echo $did_you_knowRecords [$rand_key]['content'] ?>
Let me know if this helps.
Tom
Re: [Tom P] Randomize List But only Show One Record
By Mohaukla - April 17, 2012
Thanks Tom
Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.
"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"
Re: [justritedesign] Randomize List But only Show One Record
By Rohwer - May 11, 2012 - edited: May 11, 2012
Re: [Rohwer] Randomize List But only Show One Record
By Rohwer - May 11, 2012
Re: [Rohwer] Randomize List But only Show One Record
By Jason - May 14, 2012
Using the techinque above, you should be able to extract a single record.
for example:
$randomRecord = $myRecords[$rand_key];
Providing you get $myRecords as the result of a getRecords() call, you should then be able to access your upload field normally.
For example:
<?php foreach ($randomRecord['uploadField'] as $upload): ?>
...
<?php endforeach ?>
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Randomize List But only Show One Record
By Rohwer - May 14, 2012 - edited: May 14, 2012
Thank you one more time. Support here is amazing and it is very appreciated.
- Rohwer