Multiple Input field

A

Anonymous

Guest
try this ..

# <form method=post action=products.php>
# <input name="file[]" type="text">
# .
# .
# .
# .
# <input name="file[]" type="text">
# ?>


//now in php it will already be and array

if you echo $file = $_POST['file']; you will get an array.

so do a foreach on $file...

my example.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">

Name:<input type="text" name="name[]" value="firstname"/>

Name 2:<input type="text" name="name[]" value="Lastname" />

<input type="submit" value="submit" />

</form>

<?php

$name = $_POST['name'];

foreach($name as $names){
echo "$names<br>";
}

out up was

firstname

Lastname
 
Let me see if I understand what you are doing...

you have a db the the following

---------------------------------
| id | qty | price |
---------------------------------
| 1 | 5 | 4.00 |
---------------------------------
| 2 | 6 | 1.00 |
---------------------------------
| 3 | 1 | 10.00 |
---------------------------------


you have a form with, lets say 3 fields. And when you enter a qty# in those fields it will, it will store them an array.. You then query the db matching the qty#s in the array with the qtys in the db getting the id from the db that. If this is the approach you want to use it will not work... What if you have one or more qty that have the same qty# in the db... You might conflict with another record...

If this is the case.. My approach would be to create a dropdown menu that result thee qty from the db.

But I will need in more details on what you would like to acheive.
 
After geting to data from the db i would us the do { } while() function... To display your fields... If the qty is update.. I would update the db and then display the updated info on an result page... But this is what I would do.. You could ask around to find out what others would do. I hope this was helpful.
 
Back
Top