Jump to content

Display results in 3 column layout


DeltaDave

Recommended Posts

I am trying to get the results from a query to display over three columns.

This is what I have so far that just displays the result in a single column

<?php
  // create short variable names
  $searchtype=$HTTP_POST_VARS['searchtype'];
  $searchterm=$HTTP_POST_VARS['searchterm'];

  $searchterm= trim($searchterm);

  if (!$searchtype || !$searchterm)
{
   echo ' <p class="result14"><span class="body14VBR">Please enter your search criteria.';
    exit;
  }
  
  $searchtype = addslashes($searchtype);
  $searchterm = addslashes($searchterm);

  $link = mysql_connect('localhost:8889', 'root', 'root');

  if (!$link)
  {
     echo 'Error: Could not connect to database.  Please try again later.';
     exit;
  }

mysql_select_db('database');
  $query = "select * from source where ".$searchtype." like '%".$searchterm."%' order by ID";
  $result = mysql_query($query);

$num_results = mysql_num_rows($result);
echo '<p class="result14"><span class="body14VBG">Member Listing </span></p>'; 



  for ($i=0; $i <$num_results; $i++)
  {

     $row = mysql_fetch_array($result);
echo '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=5 COLSPAN=1>';
echo '<tr>';
echo '<td WIDTH=300 VALIGN=CENTRE HEIGHT =12><p class="style28"><span class="body12VB">';
echo stripslashes($row['company']);
echo '</span></p></td>';
echo '</tr>';
echo '<tr>';
echo '<td WIDTH=300 VALIGN=CENTRE HEIGHT =12><p class="address"><span class="body12V">';
$address_format = str_replace(',',',<br />',stripslashes($row['address']));
echo $address_format;
echo '</span></p></td>';
echo '</tr>';
echo '<tr>';
echo '<td WIDTH=300 VALIGN=TOP HEIGHT =12><p class="style88"><span class="body12V">';
echo 'Contact: '.stripslashes($row['contact']);
echo '</td>';
echo '<tr>';
echo '<td WIDTH=300 VALIGN=CENTRE HEIGHT =12><p class="style88"><span class="body12V">';
echo 'Tel: '.stripslashes($row['telephone']);
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td WIDTH=300 VALIGN=CENTRE HEIGHT =12><p class="style88"><span class="body12V">';
echo 'Fax: '.stripslashes($row['fax']);
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td WIDTH=300 VALIGN=CENTRE HEIGHT =12><p class="style88"><span class="body12V">';
echo 'Email: <a href="mailto:' . ($row['email']). '">' . ($row['email']) . '</a>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td WIDTH=300 VALIGN=CENTRE HEIGHT =12><p class="style88"><span class="body12V">';
echo 'Web: <a href="http://' . ($row['website']). '"target="_blank">' . ($row['website']) . '</a>';
echo '</td>';
echo '</tr>';
echo '</TABLE>';
  }
?>

I know this may appear very amateurish code but as a noobie I would appreciate any help with this.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/118863-display-results-in-3-column-layout/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.