Link不会在ajax环境中工作

时间:2014-09-08 03:09:51

标签: php jquery ajax

我创建了我的ajax.php,但问题是我给出的链接不起作用。这是我的代码。

    // Insert a new row in the table for each person returned
while($row = mysqli_fetch_array($result))
{
    $student_id = $row['student_id']; 
    $searchResults .= "<tr>\n";
    $searchResults .= "  <td>{$row['LRN']}</td>\n";
    $searchResults .= "  <td>{$row['first_name']}</td>\n";
    $searchResults .= "  <td>{$row['last_name']}</td>\n";
    $searchResults .= "  <td>{$row['grade']}</td>\n";
    $searchResults .= "  <td>{$row['section']}</td>\n";
    $searchResults .= "  <td><a href='Student_View.php?id={$student_id}'>View</a> </td>\n";
    $searchResults .= "  <td><a href='Admin_Edit_Student_Info.php?id={$student_id}'>Update</a></td>\n";
    $searchResults .= "  <td><a href='Admin_Delete_Student.php?id={$student_id}' onclick=\"if (! confirm('Delete this student?')) return false;\">Delete</a></td>\n";
    $searchResults .= "</tr>\n";
}
}
?>

我指的是链接

<a href='Admin_Edit_Student_Info.php?id={$student_id}'>View</a>
<a href='Admin_Edit_Student_Info.php?id={$student_id}'>Update</a> and
<a href='Admin_Delete_Student.php?id={$student_id}' onclick=\"if (! confirm('Delete this student?')) return false;\">Delete</a>

我一直试图将这个问题告诉我们大约一个星期宣布id = {$ student_id}',但也许我在正确宣布它的地方错了。

3 个答案:

答案 0 :(得分:0)

试试这个!

<a href='Admin_Edit_Student_Info.php?id=<?php echo $student_id;  ?>'>Send</a>

答案 1 :(得分:0)

你也可以这样做:

$searchResults .= "<td><a href='Admin_Delete_Student.php?id=".$student_id."' onclick=\"if (! confirm('Delete this student?')) return false;\">Delete</a></td>";

答案 2 :(得分:0)

如何改变你的代码......

$student_id = $row['student_id'];
$searchResults .= "<tr>\n";
$searchResults .= "  <td>".$row['LRN']."</td>\n";
$searchResults .= "  <td>".$row['first_name']."</td>\n";
$searchResults .= "  <td>".$row['last_name']."</td>\n";
$searchResults .= "  <td>".$row['grade']."</td>\n";
$searchResults .= "  <td>".$row['section']."</td>\n";
$searchResults .= "  <td><a href='Student_View.php?id=".$student_id."'>View</a> </td>\n";
$searchResults .= "  <td><a href='Admin_Edit_Student_Info.php?id=".$student_id."'>Update</a>               </td>\n";
$searchResults .= "  <td><a href='Admin_Delete_Student.php?id=".$student_id."' onclick=\"if (!         confirm('Delete this student?')) return false;\">Delete</a></td>\n";
$searchResults .= "</tr>\n";