-2
我試圖在單擊表中的鏈接時運行對mysql的更新。 對於這個我做了3個文件:從javascript運行php更新文件
movies.php
<html>
<head>
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<script src="video.js" type="text/javascript"></script>
</head>
<?php
include 'combo_new.php';
include 'config.php';
include 'opendb.php';
$ndate = $_POST['ndate'];
$result = mysql_query("SELECT *
FROM DayMovie
WHERE FileDate LIKE '$ndate%' ORDER BY FileDate DESC")
or die(mysql_error());
echo "<table border='0'>";
echo "<tr> <th>Dato</th><th>Visninger</th><th>Handling</th></tr>";
while($row = mysql_fetch_array($result)) {
\t echo "<tr><td>";
\t echo date('d.m.Y', strtotime($row['FileDate']));
\t echo "</td><td>";
\t echo $row['Counter'];
\t echo "</td><td>";
\t echo "<a href='alldaymovies/{$row['FileName']}' onclick='playVideo(this.href, {$row['FileName']});' onkeypress='playVideo(this.href, {$row['FileName']});'>Se film</a>";
\t echo "</td></tr>";
}
echo "</table>";
include 'closedb.php';
?>
</html>
的Video.js
function playVideo(filename)
{
\t $.post("update.php" {"filename":filename},
\t function(data) {
\t alert("Data Loaded: " + data);
});
}
update.php
<?php
include 'config.php';
include 'opendb.php';
$filename = $_POST['filename'];
$result = mysql_query("UPDATE DayMovie SET Counter=Counter+1 WHERE FileName='$filename'")
or die(mysql_error());
include 'closedb.php';
?>
但是有件事不正確的在這裏...任何人都可以看到,我錯了?
你有什麼問題?你得到哪些錯誤?什麼不工作? – 2015-02-07 09:55:38