Working on making an inventory page for work. I have written a page that will loop through my data base and display all of the items in there.
include 'auth.php'; //to change login, please authenticate
$sql="SELECT * FROM `inventory` ORDER BY `id` asc;";
$result=mysql_query($sql);
while($rows = mysql_fetch_array($result)){
echo $rows["name"];
<input type="text" name="<? echo $rows["id"]; ?>" id="<? echo $rows["id"] ?>" placeholder="Who will go in here?" />
}
The above code is doing what I want. I would like to put this in a form and have a submit button. Let’s say the form is
<form method="POST" action="page.php">
Now I want to be able to write a page.php so that it can handle all of the data regardless of the number of items. In the past I have done the following
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$phone=$_POST['phonenum'];
$email = $_POST['email'];
$age = $_POST['b18'];
But that won’t work as I will have an unknown amount of post. Please write any code you like. I prefer document pages.
$_POST is just an ordinary hash array, so you can loop over it
edit
well you need to do some special adjustments, if your values are array values (POST key with [] at the end of the name)
edit
it’s of no use if you try
because you don’t know the name of the variables;