typical_finnish;10994434 wrote:question 1 is, am i correct, can it done that way?
Not really; take a look at the information you'd be POST'ing to 'food-order-database.php' and you'll find that you're missing an important piece.
When your example form is submitted, the $_POST array will look something like:
Array
(
[food_quantity] => 3
)
Now, based on that information, can you tell me which product this quantity is referring to?
One way to maintain the relationship of quantity to product would be to include some identifying value (such as an AUTO_INCREMENT value from the D😎 in the field name itself, e.g. you'd have HTML form inputs like:
<input type="text" name="food_quantity[123]">
which, when submitted, would result in the $_POST array looking more like:
Array
(
[food_quantity] => Array
(
[123] => 3
)
)
which is much more beneficial, since you can now relate product id #123 to the entered quantity of '3'.
typical_finnish;10994434 wrote:question 2 is, is that also easier with array, and if how 🙂 (i still dont know how to use array)
I believe I already answered both questions (and, if not: "yes" and "see above"), but I'd still like to address that last statement you've made (twice now).
Why on earth are you working with relational databases and user input when you haven't learned one of the basic variable types - not only in PHP, but in programming in general? I would reference the adage about 'learn to crawl before you walk,' but I don't think even that description does your current situation justice (it'd be more like 'learn to crawl before entering the Olympic skating competitions').