ajloun
10-12-2009, 05:50 AM
Hello
i use this code to delete users from mysql tabel , all ok but when click name it deletes wrong user . the last member gets deleted ..dont know why .. but . i use PHP paased in Javascript to call the id . and it does call id but wrong id .
get Rows. for mysql
$result = mysql_query("SELECT * FROM ".$DB->prefix("users")." WHERE level=0 ");
$rows = mysql_num_rows($result);
<script type="text/javascript">
<!--
function confirmation3() {
var answer = confirm("<? echo "are u sure ? "; ?>")
if (answer){
window.location = "user.php?action=st&id=".$row['id']."";
}
else{
alert("<? echo "Canceled"; ?>")
}
}
//-->
</script>
delete link
<a href='#' onclick='confirmation3(); return false;''>delete</a>
do delete
$id = HtmlSpecialchars($_GET['id']);
$query = mysql_query("DELETE FROM ".$DB->prefix("users")." WHERE id='$id'")
or die("cant users");
the thing is if i dont use the href in javascript all work ok just like
<a href=user.php?action=st&id=".$row['id'].">delete</a>
i use this code to delete users from mysql tabel , all ok but when click name it deletes wrong user . the last member gets deleted ..dont know why .. but . i use PHP paased in Javascript to call the id . and it does call id but wrong id .
get Rows. for mysql
$result = mysql_query("SELECT * FROM ".$DB->prefix("users")." WHERE level=0 ");
$rows = mysql_num_rows($result);
<script type="text/javascript">
<!--
function confirmation3() {
var answer = confirm("<? echo "are u sure ? "; ?>")
if (answer){
window.location = "user.php?action=st&id=".$row['id']."";
}
else{
alert("<? echo "Canceled"; ?>")
}
}
//-->
</script>
delete link
<a href='#' onclick='confirmation3(); return false;''>delete</a>
do delete
$id = HtmlSpecialchars($_GET['id']);
$query = mysql_query("DELETE FROM ".$DB->prefix("users")." WHERE id='$id'")
or die("cant users");
the thing is if i dont use the href in javascript all work ok just like
<a href=user.php?action=st&id=".$row['id'].">delete</a>