私は3ページあります:
1)index.php(select.phpから結果を取得し、それらをdiv#resultに配置します)
2)select.php(MySQLのテーブルにループします)
3)delete.php(user_idをパラメーターとして取得し、MySQLのテーブルから削除します)。
私の目標は:ユーザーが削除をクリックした後です!更新された結果を表示するには(変更/削除後)
MySQLのテーブルから
私の問題は、jQueryに伝える方法がわからなかったことです:listen process delete.php?id = 123&then
delete.phpにリダイレクトせずにindex.phpにとどまりながらselect.phpをリロードします
そのため、ユーザーは実際に何が起こっているのか、または自分がリダイレクトされていることを認識していません
別のページ。
index.php
<html>
<title>a</title>
<head>
<script type="text/javascript" src="jquery-1.8.0.js"></script>
<script type="text/javascript">
$(function() {
$('#result').load('select.php');
});
</script>
</head>
<body>
<div id="result"></div>
</body>
</html>
select.php
<?php
$con = mysql_connect("localhost","root","123");
if (!$con) { die('Could not connect: '); }
mysql_select_db("test", $con);
$result = mysql_query("select * from users");
while($rs3 = mysql_fetch_array($result)) {
echo $rs3["user_email"]." ".$rs3["user_name"]." ";
echo "<a href=delete.php?id=".$rs3[user_id].">Delete</a>";
echo "<br />";
}
?>
delete.php
<?php
$con = mysql_connect("localhost","root","123");
if (!$con) { die('Could not connect: '); }
mysql_select_db("test", $con);
$id = mysql_escape_string($_GET["id"]);
$delete = "delete from users where user_id='{$id}'";
@mysql_query($delete);
?>
ありがとうございました。