display search results Horizontally

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bickyz
Forum Newbie
Posts: 5
Joined: Tue Dec 01, 2009 12:54 pm

display search results Horizontally

Post 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>";
}
?>
 
 
daj
Forum Newbie
Posts: 5
Joined: Sat Feb 20, 2010 1:43 pm

Re: display search results Horizontally

Post 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?
bickyz
Forum Newbie
Posts: 5
Joined: Tue Dec 01, 2009 12:54 pm

Re: display search results Horizontally

Post by bickyz »

sorry im not.
is it possible for you to brief the code here please, will be very grateful.
Post Reply