Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with arrays anf forms

Status
Not open for further replies.

milo3169

Programmer
May 2, 2007
42
Hi,

I'm trying to create a form that list row from a database and when I display the results it puts a checkbox and a text field for quantity. I am able to create an array from the checkboxes submitted and then I can display or do what ever I need to with that array. The problem that I'm having is that along with the checkboxes I need to submit the quantities along with it.

First part:


Code:
<td width='5%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
 <input type='checkbox' name='row[]' value='$row[man_pn]'>
</td>
<td width='60%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
 <p class='itemtitle'>
  $row[item_title]
 </p>
</td>
<td width='15%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
 <p class='itemtitle'>
  $row[r3_price]
 </p>
</td>
<td width='20%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
 <input type='text' value='1' name='qty' size='3'>
</td>
Second part:


Code:
foreach($_POST["row"] as $select_rows)
{
	$item_query = mysql_query("SELECT * from equipment where man_pn = '$select_rows'") or die("error: " . mysql_error());
				
	while($fetchrows = mysql_fetch_array($item_query))
	{
	    echo $fetchrows["item_title"] . " " . $fetchrows["r3_price"] . " " . $_POST["qty"] . "<br>";
	}				
}

If you look at the first part I have the checkbox field that becomes the array when submitted. Is there a way to add the QTY filed with the row[] array?

Thank you in advance
 
just make qty into an array too then in your code
Code:
foreach($_POST["row"] as [red]$i=>[/red]$select_rows)
{
    $item_query = mysql_query("SELECT * from equipment where man_pn = '$select_rows'") or die("error: " . mysql_error());
                
    while($fetchrows = mysql_fetch_array($item_query))
    {
        echo $fetchrows["item_title"] . " " . $fetchrows["r3_price"] . " " . $_POST["qty"][red][$i][/red] . "<br>";
    }                
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top