kernelgpf Posted June 6, 2007 Share Posted June 6, 2007 Alright- I've got this little script that will "auto" do things with items, such as you can check the option to stock, discard, trade, donate, etc. an item, but with tons of items. Now- I want to pass WHAT they want to do with the item through in an array, and print out what it is they are trying to do, but my problem is that because it's a radio box option for each item, with the name of it being the item's ID number, I have no way to determine what the $_POST variable's name will be, because it will depend upon what item they've chosen to do something with.. here's my code- if($_GET['action'] == "multiple"){ if($_POST['actions']) { foreach($_POST['actions'] as $key => $value) { print "player wants to $key the item $value<br />\n"; } } $query=mysql_query("select iname,itemid from items where ownerid='$sid' and equipped='no' and usf='no' and auction='no'")or die(mysql_error()); echo ' <script type="text/javascript" src="http://www.shawnolson.net/scripts/public_smo_scripts.js"></script> <form method="post" action="inventory.php?action=multiple"> <table class="tstyle5"> <tr> <th class="tstyle5" width="50">Item</th> <th class="tstyle5" width="50">Stock?</th> <th class="tstyle5" width="50">Auction?</th> <th class="tstyle5" width="50">Give Away?</th> <th class="tstyle5" width="50">Donate?</th> <th class="tstyle5" width="50">Discard</th> </tr>'; while ($row = mysql_fetch_array($query)) { echo ' <tr> <td><b>' . $row[iname] . '</b></td> <td><INPUT type="radio" value="actions[stock][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[auction][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[giveaway][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[donate][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> <td><INPUT type="radio" value="actions[discard][' . $row['itemid'] . ']" name="' . $row['itemid'] . '"></td> </tr>'; } echo ' <tr> <td> <input type="radio" name="checkall" onclick="checkUncheckAll(this);"/> <input type="submit" name="delete" value="Go!"> </td> </tr> </table> </form>'; echo '<pre>' . print_r($_POST, true) . '</pre>'; My main problem is that the "if($_POST['actions']) {" part of my code won't trigger. Any ideas? Pre-thanks to any help. Quote Link to comment Share on other sites More sharing options...
thefortrees Posted June 6, 2007 Share Posted June 6, 2007 whats this part right here? if($_GET['action'] == "multiple"){ Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted June 6, 2007 Author Share Posted June 6, 2007 If they click the form, it takes them to.. filenamehere.php?action=multiple. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 6, 2007 Share Posted June 6, 2007 Robyn...I made a script like this for a website the other day, here is my post on it. http://www.phpfreaks.com/forums/index.php/topic,143185.msg611475.html#msg611475 That will probably help you a lot. I just couldn't figure out a good way to put it into the array. Look at Frosts post. Quote Link to comment Share on other sites More sharing options...
thefortrees Posted June 6, 2007 Share Posted June 6, 2007 There are two things, but I'm not totally sure about the second one. 1) Why have if($_POST['actions'] right before a foreach($_POST['actions']? This is extremely redundant - remove the if statement and if $_POST['actions'] is not set, then it will never enter the loop. 2) Are you defining a two dimensional array with value="actions[stock][' . $row['itemid'] . ']"? I don't think you can define two dimensional arrays with HTML, just one dimensional. So maybe try removing [' . $row['itemid'] . '] from value and see if that works? Hope any of that helps Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted June 6, 2007 Author Share Posted June 6, 2007 Thanks Colin. =x Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 6, 2007 Share Posted June 6, 2007 =D No Problem. 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.