On Mon, 21 May 2001, indrek siitan wrote:
> order by rand() didn't work back in 3.22.
>
> if i remember correctly (if this doesn't work, you can try to search
> the list archives), the workaround was:
>
> SELECT col1,col2,RAND() as r FROM table ORDER BY r LIMIT 1;
Thanks. Now I am into another problem. I am not sure whether it is php
or mysql. Though it works in the command prompt of mysql. Below is the
snippet of my php script. What I am trying to do is to randomly display a
scroll from the special table. This happens when the page is loaded or
refreshed.
// sql statement
$searchStmt = "select special.contid, special.cityid, special.curr1,
special.catalogo, special.hf, special.curr2, special.vitofferta,
special.fh, special.club,
special.stars, city.city,RAND as r from special,city where
DATE_SUB(special.periodo, INTERVAL 3 DAY) >'$tdate' and
city.id=special.cityid order by r limit 1" ;
var timerID=null
var run=false
count = 10 // counter of cycles
ScrollSpeed = 800; // milliseconds between scrolls
ScrollChars = 1; // chars scrolled per time period
function Stop()
{
if(run) clearTimeout(timerID)
run=false
}
function Start()
{
Stop();
Marquee()
}
function Marquee()
{
var msg = document.forms[0].message.value;
var tmp = msg.substring(0,ScrollChars);
msg = msg.substring(ScrollChars) + tmp;
document.forms[0].message.value = msg;
if(count<200)
{
timerID = setTimeout('Marquee()',ScrollSpeed);
run= true;
count++;
}
}
<!-- end -->
</script>
<form>
<?php
while($row = mysql_fetch_object($result))
{
?>
<input name=message size=57 value="<?php echo
$row->city . ", " .
"Catalogo Prezzo" . " " .
$row->curr1 . " " .
$row->catalogo . " " .
$row->hf . ", " .
"Vitofferta" . " " .
$row->curr2 . " " .
$row->vitofferta . " " .
$row->fh; ?> ">
<?php } ?>
</form>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php