473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to handle a second array ?

hi all,

I have an old script which has a dynamically populated form where the
user chooses the items from as many list/menu as the categories
existing in the database and then on a confirm page only the items
selected are shown to be checked by the user before sending them ( to a
third script )

Now I would like to add another list/menu field in the form to let the
user choosing the quantity of each item selected, but I don't know how
to handle it in the confirm page . I use a "foreach" to display the
array of items in the next page
, but how can I show the quantity for each item too ?

I post the code of both pages below ( only the part of interest )

TIA

Johnny
FORM PAGE
<form name="form1" method="post" action="confirm.php">
<?php
$cat=mysql_query("SELECT DISTINCT category FROM table ORDER BY
id", $db);
while ($category=mysql_fetch_array($cat)) {
$array_categoy[]=$category["category"];

}

foreach($array_category as $key=>$val) {
$data_link=mysql_query("SELECT * FROM table WHERE
category='$val'",$db);
?>
<?php $label = str_replace ( "_"," ",$val) ; ?>
<p> <?php echo $label; ?></p>

// THE PART I WOULD LIKE TO ADD

<select name="quantity" id="quantity">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>

// END OF NEW PART
<select name="field[<?php $val ?>]"id="<?php $val ?>">
<option > - - - - - - - - - - - - </option>
<?php
while ($link=mysql_fetch_array($data_link)) {
$description_link= $link["product"];
$id_link = $link["id"];
$code_link = $link["code"];

print "<option value=\"$code_link = $description_link\">
$description_link </option>";

}

?>
</select>
<?php

}

?>

<input name="Submit" type="submit" value="GO ON >>">
</form>
CONFIRM PAGE
<form name="form1" method="post" action="send.php">
<p>Please check the data u entered</p>
<p>
<input name="hiddenField" type="hidden" value="<?php

foreach ($_POST['field'] as $name=>$value) {

// HOW TO ADD THE QUANTITY TOO ?

echo nl2br("$value");

}

?>">

<?php

foreach ($_POST['field'] as $name=>$value) {

$split = split("\=", $value);
$pieces = explode("=", $value);
echo nl2br("$pieces[1]<BR>");

}

?>
</p>
<input name="Submit" type="submit" value="SEND >>">
</p>
</form>

Jul 17 '05 #1
0 1290

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: lawrence | last post by:
Is there an easy way to sort a 2 dimensional array alphabetically by the second field in each row? Also, when I use sort() on a two dimensional array, it seems to work a lot like...
4
by: John Bullock | last post by:
Hello, I am at wit's end with an array sorting problem. I have a simple table-sorting function which must, at times, sort on columns that include entries with nothing but a space (@nbsp;). I...
3
by: src_mag | last post by:
Hello, I'd like to write JavaScript code that refreshes a frame once a second loading a different image each time. Basically, here's what the script would do: 0 sec load img0.gif 1 sec load...
21
by: Jaspreet | last post by:
I was working on some database application and had this small task of getting the second highes marks in a class. I was able to do that using subqueries. Just thinking what is a good way of...
3
by: Logan McKinley | last post by:
I need to draw a dot where ever the user clicks (which will be on either the form or a couple dynamically placed picture boxes). I thought the following code should work: //--- static public...
1
by: RJN | last post by:
Hi In the mainscreen I have a datagrid and from here I open new windows on click of link button. And I'm doing it through RegisterStartupScript Me.RegisterStartupScript("PopUp", _ "<script...
10
by: Dancefire | last post by:
Hi, everyone, I'm writing a program using wstring(wchar_t) as internal string. The problem is raised when I convert the multibyte char set string with different encoding to wstring(which is...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
2
bilibytes
by: bilibytes | last post by:
Hi, I have a database with a one to many relationship and i was wondering what was the best way to parse the resultset. this post explains exactly what my situation:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.