SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Multiple column output for search results?

    Hi, I'm stuck with something and I hope someone can help me out. I have a search engine that searches my database and it works great. The only problem is that the results are displayed vertically in one single column, and I would like to have them horizontally in multiple columns.
    I have tried and tried but I'm too much of a newbie to accomplish that by myself. Can anybody please help me? Here's the code for the search feature:
    -------------------------------------------------------------------------
    <?php
    if ($searchstring)
    {
    $sql="SELECT * FROM body WHERE size LIKE '%$searchstring%' ORDER BY size ASC";
    $db = mysql_connect("localhost", "user", "password");
    mysql_select_db("database",$db);
    $result = mysql_query($sql,$db);

    echo '<TABLE BORDER=0>';

    echo '<tr>';
    echo '<td>';

    echo '<center><br>Choose your sizeform method="POST" action="<?php $PHP_SELF ?>">';
    echo '<select size="1" name="searchstring" style="color:#000000; background-color:#FCBBB9; border-width:0px; border-color:#ffffff; height:10px;"><option selected value="32a">32a</option>';
    echo '<option value="32b">32b</option>';
    echo '<option value="88zz">88zz</option></select>';

    echo '<input type="submit" value="Go!" name="B1" style="color:#000000; background-color:#FCBBB9; border-width:1px; border-color:#ffffff; height:20px; width:30px">';
    echo '</center></form></td></tr>';


    while ($row = mysql_fetch_array($result))

    {
    echo '<tr><td><img src="'.$row['image'].'" width="100" height="120" border="0"></td></tr>';
    echo "<TR><TD>".$row["style"]."<br> ".$row["size"]."<br>".$row["price"];
    echo "<br><a href=\"view.php?id=".$row["id"]."\">View</a>";
    }
    }

    else
    {
    ?>
    <center><br>Choose your sizeform method="POST" action="<?php $PHP_SELF ?>">
    <select size="1" name="searchstring" style="color:#000000; background-color:#FCBBB9; border-width:0px; border-color:#ffffff; height:10px;"><option selected value="32a">32a</option>
    <option value="32b">32b</option>
    <option value="88zz">88zz</option></select>

    <input type="submit" value="Go!" name="B1" style="color:#000000; background-color:#FCBBB9; border-width:1px; border-color:#ffffff; height:20px; width:30px">
    </center>
    </form>
    <?php
    }
    ?>
    -------------------------------------------------------------------------
    Thanks in advance!

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    your mysql query looks fine

    moving to php forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •