I have three pages :
1)index.php (get results from select.php and put them into div#result )
2)select.php (loops into MySQL's table)
3)delete.php (gets user_id as a parameter and deletes it from MySQL's table).
My goal is : After user clicks on delete! to show updated results (after changes/deletes)
from MySQL's table
my problem is I could not know how to tell jQuery: listen process delete.php?id=123 & then
reload select.php while staying in index.php without redirecting to delete.php
so user actually does not see what happens or does not see that he's being redirected to
another page.
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);
?>
thank you.