jQuery未连接到.php

I am having some trouble with my jquery. I am not sure if it is connecting to doc.php but I am not getting anything inserted into my database.

I have an insert command in doc.php which I know is working.

I'm trying to create a way to update prices in a database, from doc.php, that searches out items one at a time.

The doc.php is searching by var, then updating in the same page.

The foreach loop function then, takes the var one by one, sends them to the doc.php page that then searches by var and updates into the database.

<?php

mysql_connect("", "", "") or die(mysql_error());

mysql_select_db("") or die (mysql_error());


$sql = "SELECT var FROM table";
$query = mysql_query($sql) or die (mysql_error());
while ($result = mysql_fetch_array($query)) {


$variable = array($result['var']);

foreach ($variable as $variable1) {


?>
<script src="jquery-1.7.2.min.js" type="text/javascript">

$(function() {
    var valueToSend = '<?php echo $variable1; ?>';

$.ajax({
    url: "doc.php",
    dataType: "json",
    type: "POST",
    data: { Variable: valueToSend },
    success: function (m) {
        alert(m);
    },
    error: function (e) {
      alert("Something went wrong ...: "+e.message);
    },
  }); /* end ajax*/
  e.preventDefault();
});
</script>

<?php


}


}

?>

First of all, what do you want to do with this code? If you want to read & write to db using php, ajax call is unnecessary. If you want to practice ajax & php you need to read some howto because your code is somewhere strange ;). This is nice collection of tutorials for jQuery and some for PHP read some and practice.