Jump to content

how to use form variables if the form was make with a while loop


Renlok

Recommended Posts

he i have a question, ive made a form where you can update price of things in your shop.
the form is just lots of
[code]<input type="text" name="***" size="7" value="$shopprice">[/code]
for each item in your shop each of while is got from a while loop.

my question is what sould you name the input and what sould you have to process the variables when you go to update the prices.
You should use an arary for your input. eg;

[code]
<input type="text" name="input[]" size="7" value="$shopprice">
[/code]

Then, on the processing page you can loop through all the values using...

[code]
<?php
  foreach ($_POST['input'] as $k => $v) {
    echp "$k = $v<br />";
  }
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.