|
|
|
เวลา กด search ค้าหาข้อมูล แล้วใช้งาน jquery.fancybox-1.3.4.pack.js ไม่ได้ครับ |
|
|
|
|
|
|
|
หน้าปกติครับ ตอนยังไม่ได้กด ปุ่ม search
เมื่อ กดลบข้อมูล ที่รูปถังขยะ จะมี popup ให้ลบข้อมูล ยังเป็นปกตินะครับ
หน้าโชวข้อมูลครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
@import url("news_all_css.css");
-->
}
</style>
<script type="text/javascript" src="jquery/lib/jquery-1.8.3.js"></script>
<script type="text/javascript" src="jquery/lib/jquery.mousewheel.js"></script>
<script type="text/javascript" src="jquery/lib/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="jquery/lib/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript">
// delete functions
jQuery(document).ready(function() {
jQuery('a[id^="delete_data"]').fancybox({
'width' : '30%',
'height' : '30%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe',
onClosed : function() {
parent.location.reload(true);
}
});
});
// seacrh function
jQuery(function () {
jQuery("#btnSearch").click(function () {
if($.trim($("#itemname").val())!=""){
jQuery.ajax({
url: "search.php",
type: "post",
data: {itemname: jQuery("#itemname").val()
},
beforeSend: function () {
jQuery(".loading").show();
},
complete: function () {
jQuery("#setserch").hide();
},
success: function (data) {
jQuery("#list_data").html(data);
}
});
}
});
$("#searchform").on("keyup keypress",function(e){
var code = e.keycode || e.which;
if(code==13){
$("#btnSearch").click();
return false;
}
});
});
</script>
<?php
session_start();
require_once("connect.php");
//*** Update Last Stay in Login System
$sql = "UPDATE member SET last_update = NOW() WHERE mem_id = '".$_SESSION["mem_id"]."' ";
$query = mysqli_query($con,$sql);
$strSQL = "SELECT * FROM post_home LEFT JOIN member ON member.mem_id= post_home.mem_id order by post_home.posth_id DESC ";
$objQuery = mysqli_query($con,$strSQL);
if(!isset($_SESSION['mem_id'])){
echo "Please Login!";
header("location:login.php");
//exit();
}
?>
</head>
<body id="set_background">
<form class="form-inline" name="searchform" id="searchform">
<div id="all">
<div id="header"></div>
<div style="text-align:right;"> <a href="logout.php">Log-out</a> </div>
<div id="navigation">
<div id="bar1"><a href='homepage.php' id="inline_bar">Home Page</a></div>
<div id="bar1"><a href='homepage.php' id="inline_bar">Meeting</a></div>
<div id="bar1"><a href='homepage.php' id="inline_bar">Balanced scorecard</a></div>
<div id="bar1"><a href='homepage.php' id="inline_bar">Webboard</a></div>
</div>
<div style="text-align:right;">
<input type="text" name="itemname" id="itemname" class="form-control" placeholder="Search a title" autocomplete="off">
<button type="button" class="btn btn-primary" id="btnSearch">Search</button>
</div>
<div id="content">
<div id="right">
<div id="inform_news">
<div id="setserch">
<?php
$i=0;
while($objResult = mysqli_fetch_assoc($objQuery)){
$i++;
?>
<div id="blog_news">
<div id="icon_image">
<img src="icons/news2.ico" style="width:100px;height:100px"></div>
<div id="icon_bin_edit" >
<?php
if($_SESSION["mem_id"] == $objResult["mem_id"]){
?>
<p id="icon" class="display_icon" >
<a href="edit_news_form.php?post_id=<?php echo $objResult["posth_id"];?>">
<img src="icons/edit2.ico" title="Edit" style="width:25px;height:25px"></a>
<a id="delete_data<?php echo $i;?>" href="delete_form.php?post_id=<?php echo $objResult["posth_id"];?>">
<img src="icons/delete2.ico" title="Delete" style="width:25px;height:25px"></a>
</p>
<?php
}
?>
</div>
<div id="show_sql" class="show_sql">
<a href="news.php?new_id=<?php echo $objResult["posth_id"];?>"
id="set_text_sql"><?php echo $objResult["posth_title"];?></a> [ <?php echo $objResult["posth_created"];?> ]
POST BY :<?php echo $objResult['mem_name'];?> <?php echo $objResult['mem_lastname'];?>
</div>
</div>
<?php
}
?>
</div>
<div id="loading"></div>
<div id="list_data"></div>
</div>
<div id="footer"> this is a footer
</div>
</form>
</body>
</html>
ส่งมายังหน้า search.php
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
@import url("news_all_css.css");
-->
}
</style>
<script type="text/javascript" src="jquery/lib/jquery.mousewheel.js"></script>
<script type="text/javascript">
jQuery.noConflict();
// delete functions
jQuery(document).ready(function() {
jQuery('a[id^="delete_data"]').fancybox({
'width' : '30%',
'height' : '30%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe',
onClosed : function() {
parent.location.reload(true);
}
});
});
</script>
<script type="text/javascript" src="jquery/lib/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="jquery/lib/jquery-1.8.3.js"></script>
<?php
session_start();
require_once("connect.php");
$recieve_search =$_POST['itemname'];
$sql = "SELECT * FROM post_home LEFT JOIN member ON member.mem_id= post_home.mem_id where post_home.posth_title like '%$recieve_search%' order by post_home.posth_id DESC ";
//$sql = "select * from post_home where posth_title like '%$recieve_search%'";
$objQuery = mysqli_query($con,$sql);
if(!isset($_SESSION['mem_id'])){
echo "Please Login!";
header("location:login.php");
//exit();
}
?>
</head>
<body >
<?php if(mysqli_num_rows($objQuery)==0){ ?>
<div style="text-align:center; margin-top:60px; margin-bottom:200px;">
<?php
echo "<center>Sorry, We couldn't find anything for (".$recieve_search."). Try entering a title again.</center>";
?>
</div>
<?php } ?>
<div >
<?php
$i=0;
while($objResult = mysqli_fetch_assoc($objQuery)){
$member_name = $objResult["mem_name"];
$i++;
?>
<div id="blog_news">
<div id="icon_image">
<img src="icons/news2.ico" style="width:100px;height:100px"></div>
<div id="icon_bin_edit" >
<?php
if($_SESSION["mem_id"] == $objResult["mem_id"]){
?>
<p id="icon" class="display_icon" >
<a href="edit_news_form.php?post_id=<?php echo $objResult["posth_id"];?>">
<img src="icons/edit2.ico" title="Edit" style="width:25px;height:25px"></a>
<a id="delete_data<?php echo $i;?>" href="delete_form.php?post_id=<?php echo $objResult["posth_id"];?>">
<img src="icons/delete2.ico" title="Delete" style="width:25px;height:25px"></a>
</p>
<?php
}
?>
</div>
<div id="show_sql" class="show_sql">
<a href="news.php?new_id=<?php echo $objResult["posth_id"];?>"
id="set_text_sql"><?php echo $objResult["posth_title"];?></a> [ <?php echo $objResult["posth_created"];?> ]
POST BY :<?php echo $objResult['mem_name'];?> <?php echo $objResult['mem_lastname'];?>
</div>
</div>
<?php
}
?>
</div>
</body>
</html>
หน้าที่เป็น form pupup ว่าแน่ใจที่จะลบข้อมูลหรือไม่
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
@import url("news_all_css.css");
-->
}
</style>
</head>
<script type="text/javascript">
function cancel_fancybox(){
try{
parent.jQuery.fancybox.close();
}catch(err){
parent.$('#fancybox-overlay').hide();
parent.$('#fancybox-wrap').hide();
}
}
</script>
<body>
<?php
$recieve_post_id = $_GET['post_id'];
?>
<form method="post" action="delete_new_post.php?post_id=<?php echo $recieve_post_id?>" enctype="multipart/form-data">
<div class="header">
<h3>Are you sure to delete news post?</h3>
</div>
<div >
<input type="button" OnClick="cancel_fancybox()" value="Cancel" />
<input class="Delete" id="Delete" type="submit" value="Delete News">
</div>
</div>
</form>
</body>
</html>
เวลาผมค้นหาข้อมูล เช่น the
แล้วมันจะโชว์ ที่มีคำว่า the ถ้าผม กดลบข้อมูล ที่เป็นรูปถังขยะ มันกลับส่งค่าไปอีกหน้า โดยไม่มี popup โชว์หน้าเดิม
ผมไม่รู้จะแก้ตรงไหนครับ ไม่รู้ว่าผิดตรงไหนครับ ใครรู้ช่วยบอกหน่อยครับ
Tag : PHP
|
ประวัติการแก้ไข 2015-07-24 06:02:04
|
|
|
|
|
Date :
2015-07-24 05:59:05 |
By :
adiphong1 |
View :
1456 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใน search.php
Code (PHP)
<script type="text/javascript" src="jquery/lib/jquery-1.8.3.js"></script> // ต้องมาก่อนเพื่อน
<script type="text/javascript" src="jquery/lib/jquery.mousewheel.js"></script>
<script type="text/javascript" src="jquery/lib/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="jquery/lib/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
|
|
|
|
|
Date :
2020-06-04 22:19:36 |
By :
PhrayaDev |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|