array


#1

Ok, So what I need is a way for arrays to combine. My basic structure is going to look like this for the form that needs submission:

[code]





[/code] then on the page it submits to, I need an array to form that will combine all the inputs to looks something like this:

“name” “name1”; “name” “name1”; “name” “name1”;…

where the first set is the first name and name1, second is second, third is third, etc.
The string of arrays will only end when there are no more left, so if there were 6, it would combine 6. how do I do something like this?


#2

You mean you get a hash ( pardon my perlism, an associative array ) with array1 keys and array2 values?

[php]
$array_result = array(); // Array containing the structure you want
$array_1 = $_POST[‘name’]; // Array containing the ‘name’ values
$array_2 = $_POST[‘name1’]; // Array containing the ‘name1’ values

foreach ( $array_1 as $key )
{ $value = array_shift( $array_2 );
$array_result[$key] = $value;
}
[/php]

This is of course assuming both arrays have the same length.


#3

Ok so I need to know how this code:

[code]

<?php // Query member data from the database and ready it for display $sql1 = mysql_query("SELECT * FROM products where id='".$pid."'"); while($row = mysql_fetch_array($sql1)){ $product =$row["product"]; $pid=$row["id"]; ?> <?php // Query member data from the database and ready it for display $sql4 = mysql_query("SELECT * FROM labels where item_id='".$pid."'"); while($row = mysql_fetch_array($sql4))for($i=0; $i<1; $i++){ $label =$row["label"]; $lid=$row['id']; echo $label; ?> <?php // Query member data from the database and ready it for display $sql3 = mysql_query("SELECT * FROM options where item_id='".$pid."' && label_id='".$lid."'"); while($row = mysql_fetch_array($sql3)){ $option =$row["option"]; ?> <?php echo $option; ?> <?php

}
?>

<?php } ?> <?php }?>

If this product is for someone other than the listed, change it, otherwise leave it:

[/code] specifically this part: [code]<?php // Query member data from the database and ready it for display $sql4 = mysql_query("SELECT * FROM labels where item_id='".$pid."'"); while($row = mysql_fetch_array($sql4))for($i=0; $i<1; $i++){

$label =$row[“label”];
$lid=$row[‘id’];
echo $label;
?>


<?php // Query member data from the database and ready it for display $sql3 = mysql_query("SELECT * FROM options where item_id='".$pid."' && label_id='".$lid."'"); while($row = mysql_fetch_array($sql3)){ $option =$row["option"]; ?> <?php echo $option; ?> <?php

}
?>

[/code]
I need to create an array from the name(1,2)[] parts. The thing is, they are going to be pulled in a loop and return all results. so there could be multiple name1[]'s name2[]'s or name[]'s. I need to know how I would combine each one in it’s loop to make part of a string. thing is, the first time name[] would be included, second time it wouldn’t be included. then the arrays combine to make one. so the final array looks like this
name[] name1[] name2[] name1[] name2[] name1[] name2[]. etc. anyhelp on this?