好的,我有一个数据库,我正在搜索业务结果。我有以下代码
<?php
REQUIRE('config.php');
$q = mysql_real_escape_string(ucfirst(trim($_REQUEST['q'])));
$result = mysql_query("SELECT * FROM gj WHERE name LIKE '%$q%' OR cat1 LIKE '%$q%' OR cat2 LIKE '%$q' OR cat3 LIKE '%$q' ORDER by name") or trigger_error(mysql_error());
$rows = mysql_num_rows($result);
if($rows == 0){
}
echo " <div id='title'>Search for "$q"<div class='right'>$rows business";if($rows > 1){echo "es";}elseif($rows == "0"){echo "es";}echo" found</div></div>";
while($row = mysql_fetch_array($result))
{
$id=$row['id'];
$name=$row['name'];
$phone=$row['phone'];
$website=$row['website'];
$city=$row['city'];
$address=$row['address1'];
$zipcode=$row['zipcode'];
$sponsored = $row['sponsored'];
$addressmap = preg_replace('/\s/', '+',$address);
$citymap = preg_replace('/\s/', '+',$city);
//Start While Loop
echo"<div id='listing'>
<div id='mainlisting'>
<div class='name'>
<a href='./more.php?id=$id' class='";if($sponsored != 1){echo "red";}else{echo"sponsored";}echo"'>$name</a> <div class='right'>$phone</div>
</div>
<div class='other'>
$address, $city, CO $zipcode
|<a target='_blank' href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=$addressmap,+$city+CO&&&ie=UTF8&hq=&hnear=$address,+$city,+Colorado+$zipcode&safe=active&&&t=h&z=14&iwloc=A&output=embed' rel='lyteframe' class='";if($sponsored != 1){echo "red";}else{echo"sponsored";}echo"' title='$name' rev='width: 500px; height: 500px; scrolling: no;'> See Map</a><br/>
<a href='#' class='";if($sponsored != 1){echo "red";}else{echo"sponsored";}echo"'>";if($website != null){ echo "<a target='_blank' href='$website' class='";if($sponsored != 1){echo "red";}else{echo"sponsored";}echo"'>Website</a> |";}echo" <a href='#' class='";if($sponsored != 1){echo "red";}else{echo"sponsored";}echo"'>More Info</a>
</div>
</div>
</div><!--/LISTING-->";
}
然后我回复列表名称,电话,网站,地址和可点击的地图。现在我想订购每种ABC样式。因此,第一个列表显示A由它,第二个列表显示B旁边等等(就像在Dex Knows上搜索业务时会发生什么)...我是一个PHP新手,所以任何帮助都将非常感激。
答案 0 :(得分:3)