DeltaDave Posted August 9, 2008 Share Posted August 9, 2008 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 More sharing options...
The Little Guy Posted August 9, 2008 Share Posted August 9, 2008 Give this a try: http://phpsnips.com/snippet.php?id=53 Link to comment https://forums.phpfreaks.com/topic/118863-display-results-in-3-column-layout/#findComment-612099 Share on other sites More sharing options...
DeltaDave Posted August 9, 2008 Author Share Posted August 9, 2008 Thanks TLG I will give that a go but being a complete novice I am not entirely sure how to integrate my existing code into that snippet. But I am game to try. Thanks Link to comment https://forums.phpfreaks.com/topic/118863-display-results-in-3-column-layout/#findComment-612267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.