Quantcast
Channel: Most efficient way to order a list by a preset random - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Most efficient way to order a list by a preset random

$
0
0

I have a online PHP system where users vote different awards for their friends, however I am finding that the awards in the middle of the page and at the bottom get less votes overall. I would prefer this to be evenly distributed so came up with ordering the list of awards by random to make it different each time you load the page.

This however seems to confuse users as then they save or revisit the page everything moves, is there a way that I can order the list randomly but save this order for that user, meaning it's different for each user.

The list of votes comes from a database and the names of the awards are preset.

Do you know a way to do this?

In the end I used:

  //Shuffle & Organise    if(is_numeric($pg)) { $start = ($pg*15)-14; $end = $pg*15; $pg = (int) $pg; } else { $start = 1; $end = 15; $pg = (int) 1; }    if($end>count($vote_name)) { $end = count($vote_name); }    $vote_boxes = range($start,$end);    srand($user['id']);     shuffle($vote_boxes);  //Create the voting boxes + js    foreach($vote_boxes as $row) {        $content .= vote_form($row);    }

Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images