hi i am tring to insert one table data to another using checkbox my flow is people check in checkbox and submit checkbox value will be pass in the query and insert data into another table my code is:
<form action="form.php" method="post">
<input type="checkbox" name="chk1" value="701" />
i am agree
<input type="checkbox" name="chk1" value="702" />swapan sen
<input type="checkbox" name="chk1" value="Babli sen" /> Babli Sen <br />
<input type="submit" name="submit" value="submit" />
$query="INSERT INTO table2 (player_id,player_name,player_url) SELECT player_id,player_name,player_url FROM table1 WHERE player_id = ('".$checkbox1."')";
mysql_query($query) or die (mysql_error());
echo "Record is inserted";
i can get messege "record is inserted" but in database i don't get any data somebody plz help thank in advance
I've never seen an INSERT and SELECT query used in this manner before. If you want player_id,player_name,player_url from table1 to go into table2, then do your SELECT for table1 and put the values into hidden fields as part of the form, then when the user clicks the checkbox, you'll have all the data from all the fields, including the info from table1, to INSERT into table2.
By the way, you are using deprecated syntax. You should be using PDO syntax. Your code as is is subject to being hacked.
This topic is now closed. New replies are no longer allowed.