Nicholas Posted April 15, 2010 Share Posted April 15, 2010 im trying to make a logs system for my lottery mod. but i think ive done the file completely wrong im trying to make it similar to RogueVampires but without the 10 winners just 1 winner also without the lottery ticket number that won it... just the Name of the player and amount they won. this is rougevampires main page of the logs http://www.roguevampires.net/raffle_winners.php which out how mine is set up and works... but... when you click on a raffle ticket that has been completed for example raffle 17616 has been completed. the link says this once clicked on "Raffle 17616" http://www.roguevampires.net/raffle_winners.php?id=17616 on my game with this sql below; it say everything kinda like how RogueVampires has up it. but my link is. http://www.criminal-madness.co.uk/lottery_win.php once on that page it say this... Last 25 Lottery Tickets Wins Raffle 2 Raffle 1 but when you click on say "Raffle 2" it just stay on the same page but the link says http://www.criminal-madness.co.uk/lottery_win.php?ID=2 if anyone can help me with this file it be great. my coding mind has gone elsewhere for while now and i cant think of anything about coding lol... if you can... could you recode it for me so its better... doesnt have to be secure as i can do that bit but i just cant figure out how to create the stupid file... as i dont think its meant to be in Functions lol. CREATE TABLE IF NOT EXISTS `lotterywins` ( `ID` int(11) NOT NULL auto_increment, `username` varchar(255) NOT NULL, `amount` int(11) NOT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `ID` (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `lotterywins` (`ID`, `username`, `amount`) VALUES (1, 'Blade Runner', 1000), (2, 'Blade Runner', 1000); NOTE: i inserted these SQL into the database myself thro the database, not thro a cron file. but it shouldnt be hard to create the insertation for these really should it? it be something like this for example... $db->query("INSERT INTO lotterywins VALUES (''{$r['ID']}, {$ir['username']}, {$r['amount']}"); <?php include "globals.php"; $_GET['ID'] = (isset($_GET['ID']) && is_string($_GET['ID'])) ? stripslashes(trim($_GET['ID'])) : FALSE; switch($_GET['ID']) { case 'ID': ID(); break; default: index(); break; } function index() { global $db,$ir,$c,$h,$userid; print "<h2>Last 25 Lottery Tickets Wins</h2>"; print "<center><table width='18%' cellspacing='1' class=table border='1' bordercolor='#636363'></center>"; $get_wins = sprintf("SELECT `ID` FROM lotterywins ORDER BY `ID` DESC LIMIT 25"); $do_wins = $db->query($get_wins); while($wins = $db->fetch_row($do_wins)) { print "<tr>"; print "<td align='center'>[url='lottery_win.php?ID=".abs(intval($wins[']Raffle ".number_format($wins['ID'])."[/url]</td>"; print "</tr>"; } print "</table>"; } function ID() { global $db,$ir,$c,$h,$userid; print "<center><table width='50%' cellspacing='1' class=table border='1' bordercolor='#636363'></center>"; print "<tr>"; print "<th width='25%'>Name</th>"; print "<th width='25%'>Amount</th>"; print "</tr>"; $get_wins = sprintf("SELECT `ID`, `username`, `amount` FROM lotterywins"); $do_wins = $db->query($get_wins); while($wins = $db->fetch_row($do_wins)) { print "<tr>"; print "<td align='center'>".stripslashes($wins['username'])."</td>"; print "<td align='center'>".number_format($wins['amount'])."</td>"; print "</tr>"; } print "</table>"; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Curt Posted April 18, 2010 Share Posted April 18, 2010 ok so your simply trying to make a log system for your lottery system ? $db->query("INSERT INTO 'lotterywins' VALUES ('', '{$ir['username']}', '{$r['amount']}')"); First off you need to make sure the column count matches. next you need to make sure that the $r variable is defined for $r['amount'] then the above query should work. also that script is a bit confusing...what exactly are you doing with the $_GET['ID'] ?...because looks like nothing from what i see... Quote Link to comment Share on other sites More sharing options...
Nicholas Posted April 18, 2010 Author Share Posted April 18, 2010 yes im trying to get a logs system for my lottery system. also i know about that insertation query, it was just an example. but like i said... i just cant think of how to create this stupid logs system, my mind just wont connect and remember how to do it lol. in Function ID() i changed $get_wins = sprintf("SELECT `ID`, `username`, `amount` FROM lotterywins"); into $get_wins = sprintf("SELECT `ID`, `username`, `amount` FROM lotterywins WHERE (`ID` = ".abs(intval($_GET['ID'])).")); but the page just refreshes when i click on the raffle ID on Function Index() cant get it to work... Quote Link to comment Share on other sites More sharing options...
Djkanna Posted April 18, 2010 Share Posted April 18, 2010 That would be because you aren't calling the ID function. the action equals the case then the GET method equals the ID. So with your naming ?ID=ID&ID=theidhere Quote Link to comment Share on other sites More sharing options...
Nicholas Posted April 18, 2010 Author Share Posted April 18, 2010 is there any chance you can help me by recoding it for me to make it work? it will be very greatful. :) i know it sounds like im asking you to do all the work for me... but i just cant think of anything on how to get this script to work lol. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted April 18, 2010 Share Posted April 18, 2010 All you need to do is change the link. This <a href='lottery_win.php?ID=".abs(intval($wins['ID']))."'> Becomes this: <a href='lottery_win.php?ID=ID&ID=".abs(intval($wins['ID']))."'> Quote Link to comment Share on other sites More sharing options...
Nicholas Posted April 18, 2010 Author Share Posted April 18, 2010 <a href='lottery_win.php?ID=ID&ID=".abs(intval($wins['ID']))."'> tried that... it still just refreshed Function Index() page lol... this is the script i have at moment <?php include "globals.php"; $_GET['ID'] = (isset($_GET['ID']) && is_string($_GET['ID'])) ? stripslashes(trim($_GET['ID'])) : FALSE; switch($_GET['ID']) { case 'ID': ID(); break; default: index(); break; } function index() { global $db,$ir,$c,$h,$userid; print "<h2>Last 25 Lottery Tickets Wins</h2>"; print "<center><table width='18%' cellspacing='1' class=table border='1' bordercolor='#636363'></center>"; $get_wins = sprintf("SELECT `ID` FROM lotterywins ORDER BY `ID` DESC LIMIT 25"); $do_wins = $db->query($get_wins); while($wins = $db->fetch_row($do_wins)) { print "<tr>"; print "<td align='center'>[url='lottery_win.php?ID=".abs(intval($wins[']Raffle ".number_format($wins['ID'])."[/url]</td>"; print "</tr>"; } print "</table>"; } function ID() { global $db,$ir,$c,$h,$userid; print "<center><table width='50%' cellspacing='1' class=table border='1' bordercolor='#636363'></center>"; print "<tr>"; print "<th width='25%'>Name</th>"; print "<th width='25%'>Amount</th>"; print "</tr>"; $get_wins = sprintf("SELECT `ID`, `username`, `amount` FROM lotterywins WHERE (`ID` = %u)", abs(@intval($_GET['ID']))); $do_wins = $db->query($get_wins); while($wins = $db->fetch_row($do_wins)) { print "<tr>"; print "<td align='center'>".stripslashes($wins['username'])."</td>"; print "<td align='center'>".number_format($wins['amount'])."</td>"; print "</tr>"; } print "</table>"; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Nicholas Posted April 18, 2010 Author Share Posted April 18, 2010 fixed. working now thanks for the help everyone. just got to add the insertation bit now :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.