Jump to content

Add, Update And Delete On Same Page


son

Recommended Posts

I have a file where I can add new colours to database table. Now I would like to have in same file underneath form to add new colour the option to either update or delete a colour. I display the current colours as:

echo "<h2>Existing colours</h2>";$q = 'SELECT colour_id, colour FROM colours ORDER BY colour';$r = mysqli_query($dbc, $q);while (list($colour_id, $colour) = mysqli_fetch_array($r, MYSQLI_NUM)) {echo "<form action=\"colours.php\" method=\"post\"><input type=\"text\" name=\"colour\" id=\"colour\" size=\"20\" maxlength=\"10\" value=\"$colour\"><input type=\"hidden\" name=\"changed\" value=\"TRUE\" /><input type=\"submit\" name=\"submit\" value=\"Update\" /></form>\n";}

but am a bit lost when it comes down to having just one input field for each colour with an update and delete button next to that runs the necessary queries. How would you do this? Maybe it could even be put together with the new insertion of colours? What is the best practice for those things?Many thanks,Son

Link to comment
Share on other sites

I manage to do it now. Assigned a mode variable which is passed as hidden field from relevant form and is checked with:if ($mode == 'new') / if ($mode == 'del') / if ($mode == 'upd') Thanks,Son

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...