newttster Posted July 30, 2012 Posted July 30, 2012 Okay ... I am making a mod that is fairly involved that will be using a number of tables. So far all is going well ... except for the latest part that I am working on. For the life of me ... I can't get the $_GET to work in one portion of my code. I am actually having two problems with this. But for now .. I need the $_GET to work first ... then maybe the second problem will be taken care of that way. Before anyone asks .. I have the query echoing to the page so I know for a fact that the $_GET is not picking anything up. Okay ... so my table has these fields and they are input on a previoius step and works fine. slaveid int (11) which is key and incremental userid int (11) which is the standard pull from the users table slavename varchar (50) input on previous step jobstodo varchar (255) input on previous step tofill int(11) adds one on input from previous step slavepword varchar(50) input on previous step Here is the code ... maybe someone can find what I am missing.If you need me to clarify something, let me know. <?PHP include "globals.php"; switch($_GET['action']) { case "hired": hired();break; default: hiring(); break; } function hiring()// lists all the slaves { global $db, $ir, $c, $h, $userid; $q=$db->query("SELECT * FROM slavemarket ORDER BY jobstodo"); echo'<h1><u>Hire a Slave</u></h1> Click on the hire link beside the slave you wish to hire.<br /><br />'; echo "<br /><table width=75% cellspacing=1 class='table'> <table cellspacing=1 class='table' table border=\"1\"bordercolor=\"red\"> <tr style='background:gray;'> <th>Slave ID</th> <th>Slave Name</th> <th>Position</th> <th>Hire</th> </tr>"; while($r=$db->fetch_row($q)) { echo "<tr> <td align=left>{$r['slaveid']}</td> <td align=left> {$r['slavename']} </td> <td> {$r['jobstodo']} </td> <td><a href='smslavehire.php?action=hired'> Hire </a></td></tr>"; } echo "</table><br /><br />"; echo'Changed your mind?<br /><br /> <a href="slavemarket.php">Slave Market</a><br /> <a href="explore.php">Back to town</a>'; } function hired() // when clicking the link "hire" it adds the new info into 2nd table with the added info of the one hiring { global $db, $ir, $c, $h, $userid; $_GET['ID'] = (isset($_GET['ID']) && !empty($_GET['ID']) && is_numeric($_GET['ID'])); $inq=$db->query("SELECT * FROM slavemarket WHERE slaveid= '{$_GET['ID']}'"); $m=$db->fetch_row($inq); $mslaveid=$m['slaveid']; $muserid=$m['userid']; $mslavename=$m['slavename']; $mjobstodo=$m['jobstodo']; $mslavepword=$m['slavepword']; echo"Your listing is {$mslaveid},{$muserid},{$mslavename},{$mjobstodo},{$mslavepword}<br />"; if ($ir['userid']==$m['userid']) { echo'You can\'t hire yourself.<br /><br /> <a href="slavemarket.php">Slave Market</a><br /> <a href="explore.php">Back to town</a>'; $h->endpage(); exit; } else { $db->query("INSERT INTO slavemarket2 VALUES (NULL, '{$ir['userid']}','{$ir['username']}','{$mslaveid}','{$muserid}','{$mslavename}', '{$mjobstodo}','{$mslavepword}')"); event_add($m['userid'], "You have been hired by ".$ir['username'].". Your password to access the Tool Shed is {$mslavepword}",$c); echo"You have hired {$mslavename}.<br /> You now have to go to the tool shed to deposit the tools<br /> necessary for your slave to their job.<br /> You only have to do this for the first time.<br /> After that, the tools are put into the shed at reset.<br /><br /> <a href='smtoolshed.php'>Tool Shed</a><br /> <a href='slavemarket.php'>Slave Market</a><br /> <a href='explore.php'>Back to town</a>"; $db->query("DELETE FROM slavemarket WHERE slaveid=$mslaveid"); } } $h->endpage(); ?> Quote
Lithium Posted July 30, 2012 Posted July 30, 2012 assuming you have the link like whatever.php?action=hired&&ID=some_int should work Quote
newttster Posted July 30, 2012 Author Posted July 30, 2012 assuming you have the link like whatever.php?action=hired&&ID=some_int should work Like this? <td><a href='smslavehire.php?action=hired&&ID={$_GET}'> Hire </a></td></tr>"; OR <td><a href='smslavehire.php?action=hired&&ID=slaveid'> Hire </a></td></tr>"; Quote
HauntedDawg Posted July 31, 2012 Posted July 31, 2012 <a href='smslavehire.php?action=hired&ID={$r['slaveid']}'> Hire </a> --tooshort-- Quote
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.