weixin_33726318 2014-03-30 20:50 采纳率: 0%
浏览 39

删除而不刷新

I'm trying to delete and entry without refreshing, this is what I have so far but for some reason is not working.

The information is displayed in a table an is working fine, the problem is when I try to delete something nothing happened.

This is my 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>";

and this is my 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);

    }

?> 
  • 写回答

1条回答 默认 最新

  • larry*wei 2014-03-30 20:59
    关注

    Note this:

    var myAjax = new Ajax.Updater(url,{method: 'get', paramaters: 'id='+id'});
    

    The last quote just after id shouldn't be there, I think.

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?