JayLewis Posted April 24, 2007 Share Posted April 24, 2007 Hey everyone! I've got this Lottery Script and i want it to work like this: The lottery will be every two hours... So say the lotto starts at 12 oclock, you've got till 1 oclock to buy your tickets but after that, you must wait an hour after the last lottery for the new lottery to start. Confusing Ey? Heres the code: <?php $page = 'Lottery'; $count_aantal = 0; $q1 = mysql_query("SELECT * FROM lotterij WHERE user='$this_user->id' AND name='hour'"); while($admin = mysql_fetch_object($q1)) { $count_aantal++; } $q2 = mysql_query("SELECT * FROM lot WHERE lotterij='hour'"); $win = mysql_fetch_object($q2); $count_mny = 0; $q1 = mysql_query("SELECT * FROM lotterij WHERE name='hour'"); while($admin = mysql_fetch_object($q1)) { $count_mny++; } $price = 10000; /// prijs wat de lotterij kost $mny = $count_mny * $price; /*Cron voor lotterij van elk uur*/ $q1 = mysql_query("SELECT * FROM cron WHERE name='hour'"); $day = mysql_fetch_object($q1); /*einde van cron elk uur*/ mysql_query("INSERT INTO cron (endt) VALUES($day+3600)"); /*begin post van lotterij uur*/ if(isset($_POST['submit'])) { /*checken of de users meer als 50 loten heeft,of meer als 50 wil kopen*/ if($count_aantal >=50) { Messagebox("$page","You already have more then 50 tickets."); return; } if($tickets >=51) { Messagebox("$page","You cannot buy more then 50 tickets."); return; } $geld = $price * $tickets; $geld1 = $this_user->hand - $geld; if($this_user->hand - $geld <= -1) { MessageBox("$page","You dont have enough money."); return; } /*einde check*/ // aantal $aantal= $_POST['tickets']; //$aantal keer herhalen for($i=1;$i<=$aantal;$i++){ mysql_query("INSERT INTO lotterij (id,user,tickets,name) VALUES('','$this_user->id','1','hour')"); } MessageBox("Lotery","You bought some tickets."); mysql_query("UPDATE users SET hand='$geld1' WHERE id='$this_user->id'"); return; } /*einde post*/ AddLog($this_user->id, "$this_user->username visit lottery", $tijd); echo "<table width='300' align='center'>"; echo "<form method='post' name='lotterij'>"; echo "<tr>"; echo "<th class='pic' colspan='6'>Lottery Hour</th>"; echo "</tr>"; echo "<tr>"; echo "<th class='empty' colspan='6'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th width='1%' class='empty'> </th>"; echo "<td width='49%' class='empty'>Buy: <input type'text' name='tickets' maxlength='2' class='trade'> </td>"; echo "<td width='49%' class='empty'><p align='right'>Tickets $count_aantal / 50 </p></td>"; echo "<th width='1%' class='empty'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th width='1%' class='empty'> </th>"; echo "<td width='49%' class='empty'>Ticket Cost:</td>"; echo "<td width='49%' class='empty'>".Tomoney($price)."</td>"; echo "<th width='1%' class='empty'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th width='1%' class='empty'> </th>"; echo "<td width='49%' class='empty'>Money in Pot:</td>"; echo "<td width='49%' class='empty'>".Tomoney($mny)."</td>"; echo "<th width='1%' class='empty'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th width='1%' class='empty'> </th>"; echo "<td width='49%' class='empty'>Start Time:</td>"; echo "<td width='49%' class='empty'>". date('D M jS, H:i:s', $day) ."</td>"; echo "<th width='1%' class='empty'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th width='1%' class='empty'> </th>"; echo "<td width='49%' class='empty'>Buying:</td>"; echo "<td width='49%' class='empty'>". date('D M jS, H:i:s', $tijd) ."</td>"; echo "<th width='1%' class='empty'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th width='1%' class='empty'> </th>"; echo "<td width='49%' class='empty'>Buying Time Ends:</td>"; echo "<td width='49%' class='empty'>". date('D M jS, H:i:s', $tijd+3600) ." </td>"; echo "<th width='1%' class='empty'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th width='1%' class='empty'> </th>"; echo "<td width='49%' class='empty'>Last Winner:</td>"; echo "<td width='49%' class='empty'>"; if($win->winner =='0') { echo "None"; } else { echo "".to_name($win->winner)."</td>"; } echo "<th width='1%' class='empty'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th class='empty' colspan='6'> </th>"; echo "</tr>"; echo "<tr>"; echo "<th class='pic' colspan='6'> <input type='submit' name='submit' class='knop' value='Buy'> </th>"; echo "</tr>"; echo "</table>"; echo "</form>"; /*einde lotterij van elk uur*/ echo "<br>"; ?> Link to comment https://forums.phpfreaks.com/topic/48467-lottery-script-working-but/ Share on other sites More sharing options...
papaface Posted April 24, 2007 Share Posted April 24, 2007 So whats the problem.... Link to comment https://forums.phpfreaks.com/topic/48467-lottery-script-working-but/#findComment-237007 Share on other sites More sharing options...
phpbeginner Posted April 24, 2007 Share Posted April 24, 2007 and being a true canuck it's confusing eh not ey. Link to comment https://forums.phpfreaks.com/topic/48467-lottery-script-working-but/#findComment-237012 Share on other sites More sharing options...
JayLewis Posted April 24, 2007 Author Share Posted April 24, 2007 i want it to work every hour like i said. but it doesnt. it just need the times sorting out, wich i cant do. Link to comment https://forums.phpfreaks.com/topic/48467-lottery-script-working-but/#findComment-237015 Share on other sites More sharing options...
papaface Posted April 24, 2007 Share Posted April 24, 2007 Just setup a cron job to make a particular file run every hour.... Link to comment https://forums.phpfreaks.com/topic/48467-lottery-script-working-but/#findComment-237038 Share on other sites More sharing options...
JayLewis Posted April 24, 2007 Author Share Posted April 24, 2007 n00b Link to comment https://forums.phpfreaks.com/topic/48467-lottery-script-working-but/#findComment-237042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.