我正在尝试删除和输入而不刷新,这是我到目前为止但由于某种原因无效。
信息显示在表格中,工作正常,问题是当我尝试删除没有发生的事情时。
这是我的courseData.php
<script type="text/javascript">
function deleteC(){
var url='deleteCourse.php';
var id = $F($( <?php ' . $row['courseid'] . ' ?>));
var myAjax = new Ajax.Updater(url,{method: 'get', paramaters: 'id='+id'});
<?php
echo "<table width='100%'>";
echo "<tr>
<th>Course name</th>
<th>Delete</th>
<th>Edit</th>
</tr>";
?>
<?php foreach($rows as $row):
echo "<tr>";
echo '<td><a href="#">' . htmlentities($row['coursename'], ENT_QUOTES, 'UTF-8') . '</a></td>';
echo '<td><a href="finalphp/deleteCourse.php?id=' . $row['courseid'] . '" onclick="deleteC()");"><font color="#e70404"> Delete </font> </a></td>';
echo '<td><a class="delete" id="'.$row["courseid"].'">Delette</a></td>';
echo "</tr> ";
endforeach;
echo "</table>";
这是我的deleteCourse.php
<?php
require("connect.php");
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = $_GET['id'];
echo"$id";
$con=mysqli_connect("localhost","root","","independentstudyclass");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"DELETE FROM courses WHERE courseid=$id");
mysqli_close($con);
}
?>
答案 0 :(得分:0)
请注意:
var myAjax = new Ajax.Updater(url,{method: 'get', paramaters: 'id='+id'});
我认为,id之后的最后一句话不应该存在。