Random order of set fields

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 17, 2009   (RSS)

Re: [rjbathgate] Random order of set fields

By ross - April 17, 2009

Hi there

Thanks for the post!

I think you are on the right track here. What I would do is create an array and load each value from your record into it one by one.

Then, you can randomize that array and use a foreach loop to create a <select> menu with it.

Does that make sense? Let me know where you get to with the code and we'll go from there.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Random order of set fields

Hey,

Got it going with this:

<?php
$answers = array
(
$record['wrong_answer_1'],
$record['wrong_answer_2'],
$record['wrong_answer_3'],
$record['correct_answer']
);
$possible = shuffle( $answers );
print( "<select>\n" );
foreach ( $answers as $possible )
{
print( "<option value=\"".$possible."\">$possible</option>\n" );
}
print( "</select>\n" );
?>


:) Cheers Ross