Jump to content

passing the contents of an array to another page


ScrewLooseSalad

Recommended Posts

  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'];
 
Link to comment
Share on other sites

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 by ScrewLooseSalad
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.