Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
[PHP] how can i make this pick a random line in the DB?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="IntactDev" data-source="post: 279578" data-attributes="member: 24757"><p>[PHP]<?php</p><p>$n1 = dbquery("SELECT * FROM lottery_tickets WHERE username = '" . TICKET . "' ORDER BY RAND();"); ?></p><p><?php</p><p>if(isset($_POST['pick']))</p><p>{</p><p> $WINNER = mysql_fetch_assoc(dbquery("SELECT username FROM lottery_tickets WHERE username = '". $n1 ."' ORDER BY RAND();"));</p><p> if($WINNER['username'] == ""){ $WINNER['username'] = "NONE"; }</p><p> </p><p> fMessage('ok', 'Winner: <b>'. $WINNER['username'] .'</b> ('. $N1 .')');</p><p>} ?>[/PHP]</p><p></p><p>The code makes no sense to me, but I basically added "ORDER BY RAND();" within the query. Also, take a look at MySQLi or PDO: <a href="http://devbest.com/threads/php-how-to-use-pdo.36053/#post-233130" target="_blank">http://devbest.com/threads/php-how-to-use-pdo.36053/#post-233130</a></p></blockquote><p></p>
[QUOTE="IntactDev, post: 279578, member: 24757"] [PHP]<?php $n1 = dbquery("SELECT * FROM lottery_tickets WHERE username = '" . TICKET . "' ORDER BY RAND();"); ?> <?php if(isset($_POST['pick'])) { $WINNER = mysql_fetch_assoc(dbquery("SELECT username FROM lottery_tickets WHERE username = '". $n1 ."' ORDER BY RAND();")); if($WINNER['username'] == ""){ $WINNER['username'] = "NONE"; } fMessage('ok', 'Winner: <b>'. $WINNER['username'] .'</b> ('. $N1 .')'); } ?>[/PHP] The code makes no sense to me, but I basically added "ORDER BY RAND();" within the query. Also, take a look at MySQLi or PDO: [url]http://devbest.com/threads/php-how-to-use-pdo.36053/#post-233130[/url] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
[PHP] how can i make this pick a random line in the DB?
Top