473,386 Members | 1,621 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,386 software developers and data experts.

Arrays and Forms

I have two elements in a form , a text area (justification[]) and a hidden
field (prodID[])

I have the following code as a test:

foreach($_POST['justification'] as $reason) {
echo $reason."<br>";
}
foreach($_POST['prodID'] as $pID) {
echo $pID."<br>";
}

output
item reason
item reason 2
item reason 3
item reason 4

id1
id2
id3
id4

How can i edit the code as such so that the following out put is displayed:

item reason - id
item reason 2 - id2
item reason 3 - id3
item reason 4 - id4
Many Thanks for any help in advance

Craig

Jul 17 '05 #1
2 1358
Użytkownik "Craig Keightley" <do**@spam.me> napisał w wiadomo¶ci
news:42*********************@news-text.dial.pipex.com...
I have two elements in a form , a text area (justification[]) and a hidden
field (prodID[])
I have the following code as a test:
foreach($_POST['justification'] as $reason) {
echo $reason."<br>";
}
foreach($_POST['prodID'] as $pID) {
echo $pID."<br>";
}


for($i=0;$i<count($_POST['prodID']);$i++)
echo $_POST['justification'][$i].' - '.$_POST['prodID'][$i];

Jul 17 '05 #2
foreach ($_POST['justification'] as $id => $reason) {

echo $reason;
echo $_POST['prodID'][$id];

}

Jul 17 '05 #3

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

Similar topics

2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
3
by: Fendi Baba | last post by:
I am trying to write a simple Javascript code to pass value from a listbox to another field the following is my code f=document.forms; window.alert(f.FieldList.options.length)...
2
by: Mark Hannon | last post by:
I am trying to wrap my brain around storing form elements inside variables & arrays before I move on to a more complicated project. I created this simple example to experiment and as far as I can...
36
by: raphfrk | last post by:
I have the following code: char buf; printf("%lp\n", buf); printf("%lp\n", &buf); printf("%lp\n", buf); printf("%lp\n", buf); printf("%d\n", buf-buf);
10
by: Liz - Newbie | last post by:
Does anyone know how to clear arrays? My C# books talk about creating arrays or talk about using Clear or RemoveAt but these methods don't appear to be available for my array. I have an array...
1
by: hledman | last post by:
Hello, Beginner here reading through murach's c# book and come to a point where the book doesn't give a good example of what they want you to do in the exercise. I've created an array with 5...
4
by: Arne Beruldsen | last post by:
I'm a recent convert to VB.net from VB6...and I can't believe they don't support control arrays. I have an app that uses a ton of Control Arrays...mostly labels and text boxes. I need some...
4
by: Mike P2 | last post by:
I used to use arrays in input data that will be turned into a superglobal more often, but now that I care more about xHTML validity, I don't. Validation checking websites (particularly the W3C...
9
by: Jack | last post by:
If I don't specify "ref" in the argument list when passing an array to the callee, I am passing the array (reference) by value. But this makes me confused because it actually means a "reference" of...
12
by: LayneMitch via WebmasterKB.com | last post by:
Hello everyone. I'm currently learning Javascript and doing a few exercises. One problem I'm working on takes an array of names from an xml file using Ajax and writes it to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.