通过a,b,c命令PHP MYSQL搜索

时间:2011-01-13 02:02:03

标签: php mysql logic

好的,我有一个数据库,我正在搜索业务结果。我有以下代码

     <?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 &quot;$q&quot;<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&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=$addressmap,+$city+CO&amp;&amp;&amp;ie=UTF8&amp;hq=&amp;hnear=$address,+$city,+Colorado+$zipcode&amp;safe=active&amp;&amp;&amp;t=h&amp;z=14&amp;iwloc=A&amp;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新手,所以任何帮助都将非常感激。

1 个答案:

答案 0 :(得分:3)

你可以用css来做到这一点。

li中换行并使用list-style:upper-alpha

祝你好运

点击此处http://w3schools.com/Css/css_list.asp