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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.