Jump to content

post with arrays


searls03

Recommended Posts

Ok so I need to know how this code:

<form>
<?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; 
?>

<select name="name1[]">
<?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"];
?>
<option value="<?php echo $option; ?>">
<?php echo $option; ?>
</option>
<?php

}
?>
</select>
</br>
<?php }
?>
<?php
}?>
If this product is for someone other than the listed, change it, otherwise leave it:<br />

<input ID="outputField<?php echo $id; ?>" name="name123" type="text" VALUE="..." />
<input name="qty" type="hidden" value="<?php echo $qty; ?>" />


  <input type="submit" id="hellobob<?php echo $id; ?>"  value="Submit" />

</form>

specifically this part:

<?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; 
?>
<input type="text" name="name[]" />
<input type="text" name="name2[]" />
<select name="name1[]">
<?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"];
?>
<option value="<?php echo $option; ?>">
<?php echo $option; ?>
</option>
<?php

}
?>
</select>
</br>

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?

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.