rowantrimmer
02-15-2010, 02:54 PM
Hello,
I have created a mysql table that contains the following fields
id
recipe_id
quanity
ingredient
I have sucessfully written a php script where upto 30 records can be populated into this table.
What I am struggling with is I need to allow the user to edit the recipe record
the input fields are <input type=text name=QTY[1]><input type=text name=ING[1]>
Where this could be anything between 1 and 30 sets of these tags depending on how many pairs the user entered data into.
I am guessing that I need to get the records from the table as follows...
and I only need to display the pairs of fields where the quantity field is NOT blank.
$viewmemberssql3 = "SELECT * FROM recipe_item WHERE recipe_id='$id' order by id asc";
$viewmembersquery3 = @mysql_query($viewmemberssql3,$connection) or die(mysql_error());
while ($viewmembersrow3 = mysql_fetch_array($viewmembersquery3))
{
if ($viewmembersrow3['quantity']!="")
{
print $viewmembersrow3['quantity']; print "<br>"; print $viewmembersrow3['ingredient']; print "<br>"; print $viewmembersrow3['id']; print "<br>";
}
}
This code seems to be OK but I am struggling to automatically build the tags for the form so that the user can edit them?
I am sorry if I haven't made myself very clear???????
I have created a mysql table that contains the following fields
id
recipe_id
quanity
ingredient
I have sucessfully written a php script where upto 30 records can be populated into this table.
What I am struggling with is I need to allow the user to edit the recipe record
the input fields are <input type=text name=QTY[1]><input type=text name=ING[1]>
Where this could be anything between 1 and 30 sets of these tags depending on how many pairs the user entered data into.
I am guessing that I need to get the records from the table as follows...
and I only need to display the pairs of fields where the quantity field is NOT blank.
$viewmemberssql3 = "SELECT * FROM recipe_item WHERE recipe_id='$id' order by id asc";
$viewmembersquery3 = @mysql_query($viewmemberssql3,$connection) or die(mysql_error());
while ($viewmembersrow3 = mysql_fetch_array($viewmembersquery3))
{
if ($viewmembersrow3['quantity']!="")
{
print $viewmembersrow3['quantity']; print "<br>"; print $viewmembersrow3['ingredient']; print "<br>"; print $viewmembersrow3['id']; print "<br>";
}
}
This code seems to be OK but I am struggling to automatically build the tags for the form so that the user can edit them?
I am sorry if I haven't made myself very clear???????