Page 1 of 1

display search results Horizontally

Posted: Sat Feb 20, 2010 3:37 pm
by bickyz
hi i have this code which displays search results vertically, how do i display results horizontally like 4 records in per row.

Code: Select all

 
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
?>
 
<php?
mysql_connect("localhost","user1","password"); 
    
mysql_select_db("dbimages"); 
 
$search=$_POST["search"];
$field=$_POST["field"];
 
if ($search == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
 
$result = mysql_query("SELECT * FROM tblimg WHERE upper($field) LIKE '%$search%'");
 
while($r=mysql_fetch_array($result))
{   
  
   $title=$r["firstname"];
   $message=$r["surname"];
   $imgurl=$r["imgurl"];
 
   echo "$id <br> $title <br> $message <br> $imgurl <br>";
}
?>
 
 

Re: display search results Horizontally

Posted: Sat Feb 20, 2010 3:44 pm
by daj
Probably the easiest way would be to put the results in a table and count when you have added 4 before moving to the next row.

The better way would be to create a list <UL> and display four in a row.

Are you familiar with any of these techniques?

Re: display search results Horizontally

Posted: Sun Feb 21, 2010 5:18 am
by bickyz
sorry im not.
is it possible for you to brief the code here please, will be very grateful.