Jump to content

Getting the input field of only one item


Terminaxx

Recommended Posts

Hey guys,

 

first i want to apologize for my english and hope you still understand the meaning of it.

 

I list items that you can buy and also choose the number, how many items you want to buy. Code:

foreach ($furnis as $f) {
     echo "<h3>$f->name</h3>";
     echo "<h5>".number_format($f->price, 0, ",", ".")." Taler</h5>";
     echo "$f->quantity x";
      if($money >= $f->price) {
      echo "<input name='quantity' type='number' min='1' max='$f->quantity'>";
      echo "<button type='submit' name='buy' value='$f->id'>Buy</button>";
      }else {
        echo "<button>Not enough money</button>";
       }
      }

To get the aricle, which is clicked is easily done with getting the ID:

$id = input($_POST['buy']);

Now my question is, how to get the quantity (inputfield) right?
 

When I try the same:

$quantity = input($_POST['quantity']);

I do not get the quantity. Of course I get it, if only one article is displayed, but there are many more. So instead of getting the quantity of the article the person clicked on, i get a random quantity from an other article.

 

How can I do it right?

Thanks for any help

Link to comment
Share on other sites

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.