Hey guys ben yardıma ihtiyacım var. Ben JQUERY ajax kullanarak yerine bir sunucu yanıtı ile güncelleme göndererek am bir HTML form var, bu dizin sayfası html ile güncelliyor.
The form
<form id="publishimages" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<input type="submit" name="publishimages" value="Publish Selected" />
</form>
PHP
if(isset($_POST['publish'])&&$_POST['publish']=="Publish Images"){
//array of sections that may be allowed to have multiple images
$allow_multiple=Array(1 ,7);
$id=filter_input(INPUT_POST,"id",FILTER_SANITIZE_STRING);
$section=filter_input(INPUT_POST,"section",FILTER_SANITIZE_STRING);
//change the string into an array
$id=explode(",", $id);
//use the array as id
$count=0;
//ensure only 1 pic is published for other sections which do not need gallery
if(!in_array($section, $allow_multiple )){
$query="UPDATE photos SET publish='0' WHERE publish='1' AND section='$section'";
$mysqli->query($query);
echo $mysqli->error;
}
foreach($id as $key=>$value){
$value=(int)($value);
if(is_int($value)){
$sql="UPDATE photos SET publish='1' WHERE id='$value'";
$result=$mysqli->query($sql);
echo $mysqli->error;
if($mysqli->affected_rows>0){$count++;}
}
}
echo "$count images have been set and will now appear in their respective sections";
}
JQUERY
$('#publishimages').submit(function() {
//get selected
var section=$(this).siblings("form").find("#imagesection").val();
// inside event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
var val = [];
if($(this).find(':checkbox').length >0){
$(this).find(':checkbox:checked').each(function(i){
val[i] = $(this).val();
});
}
if($(this).find(':radio').length >0){
$(this).find(':radio:checked').each(function(i){
val[i] = $(this).val();
});
}
$.ajax({
data:"publish=Publish Images&id="+ val + "§ion="+ section,
type: "POST",
url: "phpscripts.php",
success: function(msg){$("#notice").html(msg)
}
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
});
return false;
})
Bu veritabanına ekler olsa sunucu yanıt gibi görünüyor ve wat PHP ile ne istediğidir
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"Http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<link type="text/css" rel="stylesheet" href="css/admin.css" />
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script type="text/javascript" src="jscripts/jquery.MultiFile.js"></script>
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="jscripts/sitescript.js"></script>
</head>
<body>
<div class="logd_div"><span class="logd">You are logged as <span>admin</span></span> | :<a href="index.php?page=changepwd">Change Password</a> | <a href="logout.php">Sign Out</a></div>
<div class="admincontent">
Soru: neden benim sunucu yanıtı tam sayfa html değil ben PHP yankılanan am sadece yanıttır?