View Full Version : Rotating a list in an array

07-18-2010, 03:20 AM

This is my problem- I have (Through a series of dynamic drop down menus) arrived at a result which is contained within an array variable, I don’t want to display the full list just the first row, which I have done. If the info contained within that first row is suitable for the user he clicks on a button and is transferred to a thankyou page, the info in that row is then posted to a mysql table (infoaccepted). If however the info contained within that first row of info is not acceptable to the user he clicks on another button which then displays the second row of info within the array but also puts what was the first row to the bottom. This would apply not to just this user but to any other user using the same criteria from the drop down menus to arrive at the same result. Maybe not that well explained so I have added an example below:


Result array list: R1 (Displayed)-R2-R3-R4
Info accepted: R1 posted to TableA (infoaccepted) in database-Move to another page-( array list for NEXT (new) search R2-R3-R4-R1 if same criteria used)
Info not accepted: Initial display: R1(Displayed)-R2-R3-R4 -Once ‘Not acceptable button’ pressed it changes to R2(Displayed )-R3-R4-R1 (R1 posted to TableB( Infonotaccepted) in database)
If info in R2 is also not acceptable ‘Not acceptable button’ pressed again-Display changes again R3(Displayed )-R4-R1-R2 (R2 posted to TableB ( Infonotaccepted) in database) If info in R3 is acceptable –R3 posted to TableA (infoaccepted) in database-move to another page-( array list for NEXT (new) search R4-R1-R2-R3 if same criteria used)


Criteria (Same as user1)
Result array list: R4(Displayed )-R1-R2-R3
Info accepted: (Same process as above)
Info not accepted: (Same process as above)

I want to know if this is possible and if so would I use PHP code or do something directly in the Mysql database or a combination of both.
Thanks for your time

07-19-2010, 05:53 AM
i got a bit lost following that frankly, it sounds generally that you would need to pass some values in the links perhaps using $_GET to collect them ,then organise the select based on that value.

07-19-2010, 12:36 PM
Thanks for your reply, the idea in itself is just a basic loop but I don’t want Row 1 reappearing at the top of the loop every time somebody enters the same criteria, so in the interests of fairness the top row Row1 data is shown once then moved to the bottom of the list and Row 2 data moves to Row1 position and is displayed and the original R1 data is moved to the bottom of the list. The position of the data will remain in those positions until someone using the same criteria ends up on the same result, after which the rows will change again Row2 this time will be moved to the bottom of the list and Row3 will take its place at the top of the list.
I am going to try and perform this looping within Mysql using dates and a trigger if it works I will let you know if you come up with an idea on how to carry out the loop using php. I would be very grateful if you would let me know.