note 102297 added to function.rand
| From: | helsouz at gmail dot com | Date: | Mon, 07 Feb 2011 15:09:51 +0000 |
| Subject: | note 102297 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-176740@lists.php.net to get a copy of this message | ||
Well, i don't know much about php and i try to get my own solutions:
<?php
include('config.php');
$lastid= 'lastid';
$result = mysql_query("SELECT id AS $lastid FROM registered_members ORDER BY id DESC LIMIT
0,1");
while($row = mysql_fetch_array($result))
{
$lastid2= $row[$lastid];}
echo rand(0, $lastid2);
?>
This will get the latest value from ID row, once this is done, the rand($min, $max) will work. Any
inconviniet? Just need to generate random numbers between the 0 and the latest id entry on the
registered_members
----
Server IP: 69.147.83.197
Probable Submitter: 89.152.4.231
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- https://master.php.net/note/edit/102297
Del: integrated -- https://master.php.net/note/delete/102297/integrated
Del: useless -- https://master.php.net/note/delete/102297/useless
Del: bad code -- https://master.php.net/note/delete/102297/bad+code
Del: spam -- https://master.php.net/note/delete/102297/spam
Del: non-english -- https://master.php.net/note/delete/102297/non-english
Del: in docs -- https://master.php.net/note/delete/102297/in+docs
Del: other reasons-- https://master.php.net/note/delete/102297
Reject -- https://master.php.net/note/reject/102297
Search -- https://master.php.net/manage/user-notes.php