0

I want to insert into different sql table the data coming from list populated by data coming from sql table. Please help

   if(isset($_POST['submit'])){
     mysql_connect("localhost","root","") or die(mysql_error());
        mysql_select_db("edge");
        $sql = "INSERT INTO my_table (this_is_one)
                    VALUES ('".$_POST['this_is_one']."')";

    }

//Connect and select array to dropdown
$conn = mysql_connect("localhost","root","") or die(mysql_error());
        mysql_select_db("save");


$options = '';
$sql = "SELECT * FROM reg1"; 
$result = mysql_query($sql,$conn);

while($row = mysql_fetch_array($result)) {
    $options .="<option>" . $row['Last_Name'] . "</option>";
}

$menu="<form id='this_is_one' name='this_is_one' method='post' action='listpopulate.php'>
  <p><label>filter</label></p>
    <select name='this_is_one' id='this_is_one'>
      " . $options . "
    </select>
    <input type='submit' value='submit'>    
</form>";
  • 4
    And what is the problem? You forgot to execute a query? – u_mulder Mar 27 '16 at 12:52
  • i want to insert into different table data populated to select coming from other sql table. im new at sql and php. badly needed your help. thank you! – Joshua Santos Mar 27 '16 at 13:00
  • Execute a query please. – u_mulder Mar 27 '16 at 13:01
  • 1
    Your code is vulnerable to SQL injection. Please read [How can I prevent SQL-injection in PHP?](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) for information on how to fix it. In addition the `mysql_*` functions in PHP are deprecated and shouldn't be used. Please read [Why shouldn't I use mysql_* functions in PHP?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) for information on why and what to replace them with. – Matt Raines Mar 27 '16 at 13:02

0 Answers0