mburt Posted August 28, 2006 Share Posted August 28, 2006 Hi.I have a very simple question:How do I add data to my MySql database? Quote Link to comment https://forums.phpfreaks.com/topic/18901-adding-data-to-mysql-with-php/ Share on other sites More sharing options...
AndyB Posted August 28, 2006 Share Posted August 28, 2006 One method is to use an INSERT query .... but I suspect there's more to your question than that. Quote Link to comment https://forums.phpfreaks.com/topic/18901-adding-data-to-mysql-with-php/#findComment-81624 Share on other sites More sharing options...
mr. big Posted August 28, 2006 Share Posted August 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/18901-adding-data-to-mysql-with-php/#findComment-81652 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.