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" />
</form>
</body>
</html>
<?php
include("config.php");
$checkbox1=$_POST['chk1'];
if ($_POST["submit"]=="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

Recommended Answers

All 2 Replies

$_POST['chk1'] returns an array, not a single value.

thanks now able to insert data into database thank you very much for response .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.