Jump to content

Adding Data to MySql with PHP


mburt

Recommended Posts

It's not really a simple question at all.

Basically, what I do is to create a html form with one input section for each column, the input type being appropriate, i.e. radio buttons for boolean or a small set, checkboxes for enum, text or textbox for text, etc.  I use method $_POST and action = the same file name, although you could put the php in a separate file and that would be the action.  The name of each input will become a value in the POST array, so name="color" in the form input will become $_POST['color'].

Above it in the same file I put a php section that takes the POST data, gives it easier variable names, then does a MySQL INSERT query.  E.g., $c = $_POST['color'], then "INSERT INTO elephants (color, favorite_song) VALUES ('$c','$fs")";

Ullman's book "PHP and MySQL" has a good section on this.

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.