2
如何運行搜索功能?我不能顯示任何結果與此代碼,我不知道如何處理這個類和功能..我是一個新手這種代碼..請檢查我的代碼....謝謝!帶有班級和公共職能的PHP搜索
<?php
$txtsearch = $_POST['txtsearch'];
class BlogController{
public function search($txtsearch){
$mysqli = new mysqli("localhost","root","","sample_db");
$display_query = "SELECT * FROM `tb_blogs` WHERE id='$txtsearch' ";
$result = $mysqli->query($display_query);
}
}
if(isset($_POST["btnsearch"])){
echo BlogController::search();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<a href="create.php"> Create New Blog</a><br>
<form action="function.php" method="post">
<input text-align:right type="text" name="txtsearch" placeholder="search">
<input type="submit" name="btnsearch" value="Search">
<table border="1" width="60%" cellpadding="2" cellspacing="0">
<thead>
<tr>
<th width="5%">ID</th>
<th width="20%">Title</th>
<th width="20%">Author</th>
<th width="40%">Content</th>
<th width="15%">Action</th>
</tr>
</thead>
<tbody>
<?php while($blog = $result->fetch_object()): ?>
<tr>
<td><?php echo $blog->id?></td>
<td><?php echo $blog->title?></td>
<td><?php echo $blog->author?></td>
<td><?php echo $blog->content?></td>
<td>
<a href="edit.php?blog_id=<?php echo $blog->id;?>">Edit</a>
<a class ="btn_del" href="delete.php?blog_id=<?php echo $blog->id;?>">Delete</a>
</td>
</tr>
<?php endwhile?>
</tbody>
</table>
<script type="text/javascript">
$(function(){
$(".remove-btn").on('click',function(){
var is_confirm = confirm("Do you want to delete record?");
if(is_confirm){
window.location = $(this).attr('href');
}
return false;
});
});
</script>
</form>
</body>
</html>
這是行不通的,先生 – light
請回聲查詢並檢查它是否是工作 –
對不起先生..但仍然... doesn't工作 – light