我的搜索结果编码 id。
我正在显示搜索结果,目前它只会显示第一个结果,我怎样才能让它显示与搜索匹配的所有结果?
这是我的代码
<?php
$name=$_GET["q"];
if ($name<=""){echo( "");
}
else
{
$con = mysql_connect("localhost","cl49-XXX","XXX");
if (!$con)
{
die('Could not connect: line 513 ' . mysql_error());
}
mysql_select_db("cl49-xxx", $con)or die( "Unable to select database");
$result=mysql_query("SELECT * FROM products WHERE `prodname` LIKE '$name%' ")or die('Error: Line 519 ('.mysql_error().')' );
$row = mysql_fetch_array($result);
$prodID=$row['prodID'];
$prodname=$row['prodname'];
$catagory=$row['catagory'];
}
echo"
<div class='row-fluid portfolio-block'>
<div class='span5 portfolio-text'>
<img src='userpics/$prodID.jpg' height='80' width='80' alt='' />
<div class='portfolio-text-info'>
<h4>$prodname</h4>
<p></p>
</div>
</div>
<div class='span5'>
<div class='portfolio-info'>
Product ID
<span>$prodID</span>
</div>
<div class='portfolio-info'>
catagory
<span>$catagory</span>
</div>
</div>
<div class='span2 portfolio-btn'>
<a href='edit_product.php?q=$prodID' class='btn bigicn-only'><span>View</span></a>
</div>
</div> ";
?>
任何帮助都会很棒!