ScrewLooseSalad Posted March 4, 2013 Share Posted March 4, 2013 I've stored entries from a large form into an array, this array I now want to pass to the next page, but when using either "$_GET[ ]" or "$_POST[ ]", I just get in my array 'a','r','r','a','y', then the rest of the array is empty... I've followed all the documentation I can find, but nothing has worked so far; can anybody help? the variable is man[x], all the other variables from the form passed over, perhaps I've not got the syntax right for an array where i declare it in the second file? $man=$_POST['man']; Quote Link to comment https://forums.phpfreaks.com/topic/275233-passing-the-contents-of-an-array-to-another-page/ Share on other sites More sharing options...
Jessica Posted March 4, 2013 Share Posted March 4, 2013 That is nowhere near enough code for us to help you. It'd probably be best to pass it in the SESSION anyway. Quote Link to comment https://forums.phpfreaks.com/topic/275233-passing-the-contents-of-an-array-to-another-page/#findComment-1416503 Share on other sites More sharing options...
P5system Posted March 5, 2013 Share Posted March 5, 2013 Put the array as a session variable and pass it to any of the pages Quote Link to comment https://forums.phpfreaks.com/topic/275233-passing-the-contents-of-an-array-to-another-page/#findComment-1416669 Share on other sites More sharing options...
ScrewLooseSalad Posted March 5, 2013 Author Share Posted March 5, 2013 ok, I'll look into session variables, thanks Quote Link to comment https://forums.phpfreaks.com/topic/275233-passing-the-contents-of-an-array-to-another-page/#findComment-1416699 Share on other sites More sharing options...
ScrewLooseSalad Posted March 5, 2013 Author Share Posted March 5, 2013 (edited) I'm not sure that session variables are suitable, as I am working from within iframes, I want to add extra parts to the array as I go; here is my code so far, at least the code that is actually run when performing this task. My code is possibly not the best way to go about it but its my first PHP/MySQL app, and I've pretty much been learning it as I've gone along, Any help getting this array that is currently named 'man[ ]' over to the second page would be super massively appreciated! echo "<form action='actionfollowup.php?itemquantity=".$itemquantity."' method='post'><table>"; foreach ($itemBOM as $i => $value) { $query = "SELECT * FROM MainUnitP WHERE PartID like $itemBOM[$i];"; $result = $db->query($query); $num_results = $result->num_rows; $row = $result->fetch_assoc(); include ('buildform.php'); //call form building function } $i++; $itemBOM[$i] = $topplateID; $query = "SELECT * FROM MainUnitP WHERE PartID like $itemBOM[$i];"; $result = $db->query($query); $num_results = $result->num_rows; $row = $result->fetch_assoc(); include ('buildform.php'); //call form building function echo "</table>"; echo "<input type='text' name='counter' maxlength='10' value='$i' style='display: none;' size='10' readonly />"; echo "<input type='text' name='itemBOM' maxlength='10' value='$itemBOM' style='display: none;' size='10' readonly />"; echo "<input type='submit' name='builditem' value='Build'/>"; echo "</form>"; this is my formbuild.php echo "<tr><td>use "<font color='#454545'><i>$row[Part_Name]</i></font>" from: </td>"; /******************************************/ if($row[stock]>=$itemquantity) { //got enough stock at unit1 echo "<td><input type='radio' name='man[$i]' value='Stock'>unit1 Stock [ inventory $row[stock]</td><td>]</td>"; } if($row[stock]<$itemquantity) { //not got enough stock at unit1 echo "<td><input type='radio' name='man[$i]' value='Stock' disabled='disabled'>unit1 Stock [ <font color='#CCCCCC'>inventory $row[stock]</font></td><td>]</td>"; } /******************************************/ if($row[unit2_stock]>=$itemquantity) { //got enough stock at unit2 echo "<td><input type='radio' name='man[$i]' value='unit2_stock' checked>unit2 Stock [ inventory $row[unit2_stock]</td><td>]</td>"; } if($row[unit2_stock]<$itemquantity) { //not got enough stock at unit2 echo "<td><input type='radio' name='man[$i]' value='unit2_stock' disabled='disabled'>unit2 Stock [ <font color='#CCCCCC'>inventory $row[unit2_stock]</font></td><td>]</td>"; } /******************************************/ if($row[unit3_stock]>=$itemquantity) { //got enough stock at unit3 echo "<td><input type='radio' name='man[$i]' value='unit3_stock'>unit3 Stock [ inventory $row[unit3_stock]</td><td>]</td>"; } if($row[unit3_stock]<$itemquantity) { //not got enough stock at unit3 echo "<td><input type='radio' name='man[$i]' value='unit3_stock' disabled='disabled'>unit3 Stock [ <font color='#CCCCCC'>inventory $row[unit3_stock]</font></td><td>]</td>"; } /******************************************/ /******************************************/ if($row[unit2_stock]<$itemquantity) { //not got enough stock at unit2 - default check echo "<td><input type='radio' name='man[$i]' value='noselect' checked style='display: none;'></td><td></td>"; } if($row[unit2_stock]>=$itemquantity) { //got enough stock at unit2 - !default check echo "<td><input type='radio' name='man[$i]' value='noselect' style='display: none;'></td><td></td>"; } echo "</tr>"; and finally, this is the page I am trying to pass the information to, it currently only prints out the variables passed to it, as I am trying to get all the variables to be passed to it before I continue, but ultimately it will make changes to my MySQL database. echo "<h2 style='font-family: ErasDemi;'>"; echo "Building $itemquantity L-item"; if($itemquantity>1){echo "s";} echo "</h2>"; $i=0; //check that there is enough stock available foreach ($man as $i => $value) { switch ($man[$i]) { case "Stock": echo "."; break; case "unit2_stock": echo "."; break; case "unit3_stock": echo "."; break; default: echo "you haven't selected enough inventories man[$i]"; exit(0); break; } } echo "check complete<br><br>"; $i=0; foreach ($man as $i => $value) { echo "item number:".$itemBOM[$i]." is to be taken from inventory:".$man[$i]."<br>"; $i++; I really appreciate the help, I'm still learning about PHP and MySQL, Edited March 5, 2013 by ScrewLooseSalad Quote Link to comment https://forums.phpfreaks.com/topic/275233-passing-the-contents-of-an-array-to-another-page/#findComment-1416713 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.