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="Brad" data-source="post: 279594" data-attributes="member: 17995"><p>Heres a preview</p><p><a href="http://prntscr.com/3amzye" target="_blank">http://prntscr.com/3amzye</a></p><p>And here is the full code</p><p></p><p>[PHP]<?php</p><p>$n1 = dbquery("SELECT * FROM lottery_tickets WHERE username = '" . TICKET . "'"); ?></p><p><?php</p><p></p><p></p><p>$getSettings = dbquery("SELECT * FROM users WHERE username = '" . USER_NAME . "'");</p><p>$userAccount = mysql_fetch_assoc($getSettings);</p><p>?></p><p><?php</p><p></p><p>if (!defined('IN_HK') || !IN_HK)</p><p>{</p><p> exit;</p><p>}</p><p></p><p>if (!HK_LOGGED_IN || !$users->hasFuse(USER_ID, 'fuse_housekeeping_moderation'))</p><p>{</p><p> exit;</p><p>}</p><p></p><p>if(isset($_POST['pick']))</p><p>{</p><p> $N1 = rand('" . TICKET . "');</p><p> </p><p> </p><p> $WINNER = mysql_fetch_assoc(dbquery("SELECT username FROM lottery_tickets WHERE username = '". $N1 ."'"));</p><p> if($WINNER['username'] == ""){ $WINNER['username'] = "NONE"; }</p><p> </p><p> fMessage('ok', 'Winner: <b>'. $WINNER['username'] .'</b> ('. $N1 .')');</p><p>}</p><p></p><p>require_once "top.php"; </p><p></p><p>$countEnter = mysql_num_rows(dbquery("SELECT null FROM lottery_tickets")); </p><p></p><p>echo '<h1>Lotto System Records ('. $countEnter .' Entries) - ('. $countEnter * 1 .' tokens Earned) - ('. $countEnter * 1 * 2 .' Tokens Prize)</h1>';</p><p></p><p>?></p><p><p>This tool allows you to view all the user enteries for the lotto system.</p></p><p><br></p><p><form method="post"></p><p> <center><input type="submit" name="pick" value="Select Random Winner"></center></p><p></form></p><p><br><br></p><p><table align="center"></p><p><tr><td align="center" width="150"><b>Username</b></td><td align="center"><b>Numbers</b></td><td align="center" width="300"><b>Date Entered</b></td></tr></p><p><?php</p><p></p><p>$query = dbquery("SELECT username,ticket_number FROM lottery_tickets");</p><p></p><p>while($assoc = mysql_fetch_assoc($query))</p><p>{</p><p> echo '<tr><td align="center">'. $assoc['username'] .'</td><td align="center"><b>'. $assoc['ticket_number'] .'</b></td><td align="center">'. date('r', $assoc['date']) .'</td></tr>';</p><p>}</p><p></p><p>?></p><p></table>[/PHP]</p></blockquote><p></p>
[QUOTE="Brad, post: 279594, member: 17995"] Heres a preview [url]http://prntscr.com/3amzye[/url] And here is the full code [PHP]<?php $n1 = dbquery("SELECT * FROM lottery_tickets WHERE username = '" . TICKET . "'"); ?> <?php $getSettings = dbquery("SELECT * FROM users WHERE username = '" . USER_NAME . "'"); $userAccount = mysql_fetch_assoc($getSettings); ?> <?php if (!defined('IN_HK') || !IN_HK) { exit; } if (!HK_LOGGED_IN || !$users->hasFuse(USER_ID, 'fuse_housekeeping_moderation')) { exit; } if(isset($_POST['pick'])) { $N1 = rand('" . TICKET . "'); $WINNER = mysql_fetch_assoc(dbquery("SELECT username FROM lottery_tickets WHERE username = '". $N1 ."'")); if($WINNER['username'] == ""){ $WINNER['username'] = "NONE"; } fMessage('ok', 'Winner: <b>'. $WINNER['username'] .'</b> ('. $N1 .')'); } require_once "top.php"; $countEnter = mysql_num_rows(dbquery("SELECT null FROM lottery_tickets")); echo '<h1>Lotto System Records ('. $countEnter .' Entries) - ('. $countEnter * 1 .' tokens Earned) - ('. $countEnter * 1 * 2 .' Tokens Prize)</h1>'; ?> <p>This tool allows you to view all the user enteries for the lotto system.</p> <br> <form method="post"> <center><input type="submit" name="pick" value="Select Random Winner"></center> </form> <br><br> <table align="center"> <tr><td align="center" width="150"><b>Username</b></td><td align="center"><b>Numbers</b></td><td align="center" width="300"><b>Date Entered</b></td></tr> <?php $query = dbquery("SELECT username,ticket_number FROM lottery_tickets"); while($assoc = mysql_fetch_assoc($query)) { echo '<tr><td align="center">'. $assoc['username'] .'</td><td align="center"><b>'. $assoc['ticket_number'] .'</b></td><td align="center">'. date('r', $assoc['date']) .'</td></tr>'; } ?> </table>[/PHP] [/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