當我嘗試搜索形式上的東西它讓我看到了所有的變量錯誤...下面的代碼是給別人打工,但不適合我
<form action="search.php" method="get">
<input type="text" size="25" name="search" placeholder="search this site">
<input type="submit" name="submit" value="search"></form>
<?php
include("includes/connect.php");
if(isset($_GET['submit'])){
$search_id = $_GET['search'];
$query = "select * from posts where post_title like '%search_id%'";
$run = mysql_query($query);
while ($row=mysql_fetch_array($run)){
$post_id = $row['post_id'];
$post_title = $row['post_title'];
$post_image = $row['post_image'];
$post_content = $row['post_content'];
}
?>
<h2>
<a href="pages.php?id=<?php echo $post_id; ?>">
<?php echo $post_title; ?></a>
</h2>
<center><img src="images/<?php echo $post_image; ?>" width="100" height="100"></center>
<p align="justify"><?php echo $post_content; ?></p>
<?php } ?>
我認爲這個問題是有循環的功能。但不知道如何解決這個...
在您的問題中顯示錯誤消息 – 2014-11-03 16:09:22
運行此代碼時出現錯誤? – 2014-11-03 16:11:12
也可以推薦使用'mysqli'或'PDO'作爲'mysql'已折舊並且不會再更新。 – chriz 2014-11-03 16:17:39