I am trying to use ajax and pass varuables from js to php in order to insert them in a mysql table. the code below is successful in calling the php script but not passing the data
i would like to pass "num" from the following js function to "insertRow.php" - the function does activate "insertRow.php" but will not pass the data
function InsertToTable(num){
var data=num;
$.ajax({
url: "insertRow.php",
data: data,
type: "POST"
});
once the data is passed i would like to insert it in to a mysql table, the following will work if i don't use "$num" but just put a value instead
<?php
$num = $_Post['data'];
//print_r($_Post("data"));
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Schedule";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql ="INSERT INTO `temp1` (`column1`) VALUES ('$num')";
$conn->query($sql);
?>