icez Posted February 28, 2009 Share Posted February 28, 2009 Hello, First of all, I'm sorry for my bad English, I'm french, but I will do my best to correct my mistake. I'm sorry if this question as been asked many and many time, but I searched on the forum and didn't find the answer... so I decided to post. I only want to know the better and smallest way to insert in mysql a data from a dropdown. If you didn't understand my question, tell me, I will try to rewrite it. Thank you. Link to comment https://forums.phpfreaks.com/topic/147252-solved-phpmysql-dropdown-im-sorry/ Share on other sites More sharing options...
Maq Posted February 28, 2009 Share Posted February 28, 2009 * Not tested * This is a form that submits to itself and inserts your selected value into the fake table. Let me know if you have any questions about the code //include database connection here if(isset($_POST['submit'])) { $name = mysql_real_escape_string($_POST['menu']); $sql = "INSERT INTO example(name) VALUES('$name') "; $result = mysql_query($sql) or die(mysql_error()); if($result) { echo "successful! you added $name into the database"; } else { echo "failure..."; } } ?> </pre> <form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>" method="POST"> you me him her < Link to comment https://forums.phpfreaks.com/topic/147252-solved-phpmysql-dropdown-im-sorry/#findComment-773018 Share on other sites More sharing options...
icez Posted February 28, 2009 Author Share Posted February 28, 2009 Thank you very much, it work =D Link to comment https://forums.phpfreaks.com/topic/147252-solved-phpmysql-dropdown-im-sorry/#findComment-773019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.