load different sig n randomization but only diferent ids...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jim_php
Forum Newbie
Posts: 16
Joined: Sat Mar 22, 2008 6:16 am

load different sig n randomization but only diferent ids...

Post by jim_php »

hello i have one problem i want in a php
after refersh load an other sign from a database ....
i use select .... from ... where active = 'yes' order by rand() limit 1

but i dont want in one refresh load the some sign but only different

any idea ?
anto91
Forum Commoner
Posts: 58
Joined: Mon Mar 10, 2008 10:59 am
Location: Sweden

Re: load different sig n randomization but only diferent ids...

Post by anto91 »

Register the id of the previus sign in a session then add

Code: Select all

 
$where = 'WHERE `active` = "yes"'. empty($_SESSION['sign_id']) ? '' : ' AND `id` != '. (int) $_SESSION['sign_id'];
 
$query = Mysql_Query('SELECT * FROM `table` '. $where .' ORDER BY rand() LIMIT 1');
 
Post Reply