Jump to content

Trying to display results in table column rather than row


sticks

Recommended Posts

Hi all. About five years ago I had a php / mysql database made by someone.   Unfortunately I can not get hold of the person who made this database to get their help.  My problem is - at the moment the results from the database display one product per table row.  I want to change this to one product per table column with three columns per row.  I have searched and searched and tried to fix this myself but being a novice I am not succeeding. 

 

I have managed to make a page with the three columns but the same product results in each three columns. 

 

My code for the part of the page concerned is pasted below:   

<table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="label"> 
<tr> <td WIDTH="50%"> <center>
   <?php $dest = $_GET['region'];

echo "FAMILY HOLIDAYS IN $region";   ?>
</center></td><td WIDTH="50%"> 
<table BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" WIDTH="100%"> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> </table></td></tr> </table></td></tr> 
<tr BGCOLOR="#979797"> <td HEIGHT="1" colspan="5"></td></tr> <tr BGCOLOR="#336699"><td colspan="5" CLASS="text"> 
<p align="left"><br>
  Click <b><font color="#FFCC00">Package 
titles</font></b> for more information for these holidays.<br> 
</p>
</td></tr> 
<?
  $row1 = mysql_query('select id, title, imgname, info_short from products where active = 1 and region="'. $_GET['region'] . '"');
?> <?
     while($row1 = mysql_fetch_array($id)  ("<td>" . $row1 ["id"] . "</td>");
?> <tr> <td class="text" onMouseOver="this.style.cursor='hand'" onClick="document.location.href='viewproduct.php?id=<? echo $result['id']; ?>'" BGCOLOR="#336699" VALIGN="MIDDLE"> 
<p><font color=#ffcc00><b> <br> <br> <? echo($result['title']); ?> 
</b></font><br /><br /> <img style="float:left;" src="<? echo($result['imgname']); ?>" HSPACE="10"/> 
<?echo(nl2br($result['info_short']));?> </p><p align="left"><br> </p><div align="center"> 
<p> </p></div></td>
<td CLASS="text"> </td>
<td class="text" onMouseOver="this.style.cursor='hand'" onClick="document.location.href='viewproduct.php?id=<? echo $result['id']; ?>'" BGCOLOR="#336699" VALIGN="MIDDLE"> 
<p><font color=#ffcc00><b> <br> <br> <? echo($result['title']); ?> 
</b></font><br /><br /> <img style="float:left;" src="<? echo($result['imgname']); ?>" HSPACE="10"/> 
<?echo(nl2br($result['info_short']));?> </p><p align="left"><br> </p><div align="center"> 
<p> </p></div></td>
<td CLASS="text"> </td>
<td class="text" onMouseOver="this.style.cursor='hand'" onClick="document.location.href='viewproduct.php?id=<? echo $result['id']; ?>'" BGCOLOR="#336699" VALIGN="MIDDLE"> 
<p><font color=#ffcc00><b> <br> <br> <? echo($result['title']); ?> 
</b></font><br /><br /> <img style="float:left;" src="<? echo($result['imgname']); ?>" HSPACE="10"/> 
<?echo(nl2br($result['info_short']));?> </p><p align="left"><br> </p><div align="center"> 
<p> </p></div></td>
</tr> <tr><td colspan="5"><div align="center"><img src="/images/yellowbar.gif" width="600" height="1"></div></td></tr> 
<? } ?> <tr><td colspan="5" align="center" class="text"> </td>
</tr> 
</table>

 

Many thanks, Sheryll

Hi F1Fan and thanks for replying.  The code I posted was from the page I had changed to try and display three different products against a table row rather than just one as it is now.

 

I have now posted the code below for the page that currently works with one product per row. 

<? include('./connect.php'); ?>
<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Family Travel - family vacations travelling with children - family holidays - South Pacific, Asia, Australia, New Zealand, Hawaii, Europe, Cruises</title>

<meta name="Description" content="Family Travel provides family friendly information about Pacific Rim family orientated holidays.  Family Travel's business is family holidays and travelling with children on vacations">


<META NAME="keywords" CONTENT="travel family holiday holidays hotels trip tours families destinations vacations vacation cruises 
adventure sightseeing  activities tourist 
friendly kids child children 
nz new zealand Rotorua Queenstown Bay of Islands Far North South Island North
planning international  brochures deals packages tickets guide online agents">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<LINK href="site.css" type=text/css rel=STYLESHEET>
<STYLE type=TEXT/CSS>BODY {
MARGIN: 0px
}
</STYLE>



<meta name=GENERATOR content="MSHTML 6.00.2900.2802"></HEAD>
<BODY bgColor=#ffffff>
<script type='text/javascript'>

//HV Menu- by Ger Versluis (http://www.burmees.nl/)
//Submitted to Dynamic Drive (http://www.dynamicdrive.com)
//Visit http://www.dynamicdrive.com for this script and more

function Go(){return}

</script> <script type='text/javascript' src='exmplmenu_var.js'></script> <script type='text/javascript' src='menu_com.js'></script> 
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD bgColor=#ffde00 colSpan=14 height=10></TD></TR> 
<TR> <TD bgColor=#336699 colSpan=14> <TABLE cellSpacing=0 cellPadding=0 border=0> 
<TBODY> <TR bgColor=#336699> <TD width=1 bgColor=#336699> </TD><TD class=symbols vAlign=center align=middle bgColor=#336699 WIDTH="157"><IMG height=126 src="/images/newlogooldbackground.gif" width=157> 
</TD><TD width="57" bgColor=#336699><IMG SRC="images/cleardot.gif" WIDTH="20" HEIGHT="1"></TD><TD width="400" bgColor=#336699><P> </P></TD><TD bgColor=#336699 WIDTH="138"><IMG SRC="images/cleardot.gif" WIDTH="150" HEIGHT="8"></TD>
<TD class=notes align=right bgColor=#336699 WIDTH="183"><FONT COLOR="#ffde00" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif"><B><FONT SIZE="1">Mondo Travel </FONT><FONT SIZE="1"> Remuera<BR>
336 Remuera Road Remuera <BR>
Auckland<BR>
New Zealand<BR>
Ph: 
(09)5205712<BR>
Fax: (09)5206644<BR>
<A CLASS=set1 HREF="mailto:[email protected]"><FONT COLOR="#FFFFFF">email:[email protected]</FONT></A></FONT></B></FONT></TD>
<TD width="1" bgColor=#336699> </TD></TR></TBODY></TABLE></TD></TR> 
<TR> <TD bgColor=#979797 colSpan=14 height=1></TD></TR> <TR> <TD bgColor=#979797 colSpan=14 height=1></TD></TR> 
<TR> <TD bgColor=#336699 colSpan=14 height=1></TD></TR></TBODY></TABLE><br> <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" WIDTH="100%"> 
<tr> <td bgcolor="#FFFFFF" valign="top"> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="LEFT" BGCOLOR="#FFFFFF"> 
<tr VALIGN="MIDDLE" ALIGN="CENTER"><td valign="top"><IMG SRC="images/cleardot.gif" WIDTH="30" HEIGHT="1"></td><td valign="top"><table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" bgcolor="#336699"> 
<tr BGCOLOR="#ffde00"> <td HEIGHT="15" CLASS="label"> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="label"> 
<tr> <td WIDTH="50%"> <center>
   <?php $dest = $_GET['region'];

echo "FAMILY HOLIDAYS IN $region";   ?>
</center></td><td WIDTH="50%"> 
<table BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" WIDTH="100%"> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> </table></td></tr> </table></td></tr> 
<tr BGCOLOR="#979797"> <td HEIGHT="1"></td></tr> <tr BGCOLOR="#336699"><td CLASS="text"> 
<p align="left"><br>
  Click <b><font color="#FFCC00">Package 
titles</font></b> for more information for these holidays.<br> 
</p>
</td></tr> 
<?
  $row1 = mysql_query('select id, title, imgname, info_short from products where active = 1 and region="'. $_GET['region'] . '"');
?> <?
     while($result = mysql_fetch_array($row1)) {
?> <tr onMouseOver="this.style.cursor='hand'" onClick="document.location.href='viewproduct.php?id=<? echo $result['id']; ?>'" BGCOLOR="#336699" VALIGN="MIDDLE"> 
<td CLASS="text"> <p><font color=#ffcc00><b> <br> <br> <? echo($result['title']); ?> 
</b></font><br /><br /> <img style="float:left;" src="<? echo($result['imgname']); ?>" HSPACE="10"/> 
<?echo(nl2br($result['info_short']));?> </p><p align="left"><br> </p><div align="center"> 
<p> </p></div></td></tr> <tr><td><div align="center"><img src="/images/yellowbar.gif" width="600" height="1"></div></td></tr> 
<? } ?> <tr><td class="text" align="center"> </td>
</tr> 
</table></td><td valign="top"><IMG SRC="images/cleardot.gif" WIDTH="20" HEIGHT="1"></td><td valign="top"> </td></tr> 
<tr VALIGN="MIDDLE" ALIGN="CENTER"><td> </td><td><br /> </td><td> </td><td> </td></tr> 
</table><TD VALIGN="TOP" ><table> <tr><td><img src='cleardot.gif' width="1" height='7'><div id='travelmenu' style='position:relative; width:140; height:300;'><img src='cleardot.gif' width='138' height='100'></div></ 
br><img src='cleardot.gif' width="1" height='40'> </td></tr> </table></TD></tr> 
</table><br> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"> <tr BGCOLOR="#979797"> 
<td COLSPAN="14" HEIGHT="1"></td></tr> <tr BGCOLOR="#585858"> <td COLSPAN="13" HEIGHT="20" CLASS="nav" bgcolor="#336699" align="left">     Copyright 
© 2006 - 2010 Family Travel   </td><td HEIGHT="20" CLASS="nav" bgcolor="#336699" align="right">   </td></tr> 
<tr BGCOLOR="#979797"> <td COLSPAN="14" HEIGHT="1"></td></tr> </table>

<!-- IndexTools Customization Code -->
<!-- Remove leading // to activate custom variables -->
<script language="Javascript">
//var DOCUMENTGROUP='';
//var DOCUMENTNAME='';
//var ACTION='';
</script>
<!-- End of Customization Code -->
<!-- IndexTools Code v4.00 - All rights reserved -->
<script language="javascript1.1" src="http://www.familytravel.co.nz/indextools.js"></script><noscript>
<img src="http://stats.indextools.com/p.pl?a=1000629694096&js=no" width="1" height="1"></noscript><!--//-->
<!-- End of IndexTools Code -->

</body>

</html>

This page can be found at http://www.familytravel.co.nz/availableproduct.php?region=cook%20islands

 

I want to change this to three products per table row rather than just one.

 

I am definately a novice so appreciate any help.

 

Sheryll

 

 

 

 

 

 

 

 

 

 

Try this. You may need to play with colspans, but it should get you started:

 

<? include('./connect.php'); ?>
<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Family Travel - family vacations travelling with children - family holidays - South Pacific, Asia, Australia, New Zealand, Hawaii, Europe, Cruises</title>

<meta name="Description" content="Family Travel provides family friendly information about Pacific Rim family orientated holidays.  Family Travel's business is family holidays and travelling with children on vacations">


<META NAME="keywords" CONTENT="travel family holiday holidays hotels trip tours families destinations vacations vacation cruises 
adventure sightseeing  activities tourist 
friendly kids child children 
nz new zealand Rotorua Queenstown Bay of Islands Far North South Island North
planning international  brochures deals packages tickets guide online agents">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<LINK href="site.css" type=text/css rel=STYLESHEET>
<STYLE type=TEXT/CSS>BODY {
MARGIN: 0px
}
</STYLE>



<meta name=GENERATOR content="MSHTML 6.00.2900.2802"></HEAD>
<BODY bgColor=#ffffff>
<script type='text/javascript'>

//HV Menu- by Ger Versluis (http://www.burmees.nl/)
//Submitted to Dynamic Drive (http://www.dynamicdrive.com)
//Visit http://www.dynamicdrive.com for this script and more

function Go(){return}

</script> <script type='text/javascript' src='exmplmenu_var.js'></script> <script type='text/javascript' src='menu_com.js'></script> 
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD bgColor=#ffde00 colSpan=14 height=10></TD></TR> 
<TR> <TD bgColor=#336699 colSpan=14> <TABLE cellSpacing=0 cellPadding=0 border=0> 
<TBODY> <TR bgColor=#336699> <TD width=1 bgColor=#336699> </TD><TD class=symbols vAlign=center align=middle bgColor=#336699 WIDTH="157"><IMG height=126 src="/images/newlogooldbackground.gif" width=157> 
</TD><TD width="57" bgColor=#336699><IMG SRC="images/cleardot.gif" WIDTH="20" HEIGHT="1"></TD><TD width="400" bgColor=#336699><P> </P></TD><TD bgColor=#336699 WIDTH="138"><IMG SRC="images/cleardot.gif" WIDTH="150" HEIGHT="8"></TD>
<TD class=notes align=right bgColor=#336699 WIDTH="183"><FONT COLOR="#ffde00" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif"><B><FONT SIZE="1">Mondo Travel </FONT><FONT SIZE="1"> Remuera<BR>
336 Remuera Road Remuera <BR>
Auckland<BR>
New Zealand<BR>
Ph: 
(09)5205712<BR>
Fax: (09)5206644<BR>
<A CLASS=set1 HREF="mailto:[email protected]"><FONT COLOR="#FFFFFF">email:[email protected]</FONT></A></FONT></B></FONT></TD>
<TD width="1" bgColor=#336699> </TD></TR></TBODY></TABLE></TD></TR> 
<TR> <TD bgColor=#979797 colSpan=14 height=1></TD></TR> <TR> <TD bgColor=#979797 colSpan=14 height=1></TD></TR> 
<TR> <TD bgColor=#336699 colSpan=14 height=1></TD></TR></TBODY></TABLE><br> <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" WIDTH="100%"> 
<tr> <td bgcolor="#FFFFFF" valign="top"> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="LEFT" BGCOLOR="#FFFFFF"> 
<tr VALIGN="MIDDLE" ALIGN="CENTER"><td valign="top"><IMG SRC="images/cleardot.gif" WIDTH="30" HEIGHT="1"></td><td valign="top"><table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" bgcolor="#336699"> 
<tr BGCOLOR="#ffde00"> <td HEIGHT="15" CLASS="label"> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="label"> 
<tr> <td WIDTH="50%"> <center>
   <?php $dest = $_GET['region'];

echo "FAMILY HOLIDAYS IN $region";   ?>
</center></td><td WIDTH="50%"> 
<table BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" WIDTH="100%"> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> <tr> <td HEIGHT="1"></td></tr> 
<tr BGCOLOR="#336699"> <td HEIGHT="1"></td></tr> </table></td></tr> </table></td></tr> 
<tr BGCOLOR="#979797"> <td HEIGHT="1"></td></tr> <tr BGCOLOR="#336699"><td CLASS="text"> 
<p align="left"><br>
  Click <b><font color="#FFCC00">Package 
titles</font></b> for more information for these holidays.<br> 
</p>
</td></tr> 
<?
  $row1 = mysql_query('select id, title, imgname, info_short from products where active = 1 and region="'. $_GET['region'] . '"');
?> <?
$count = 1;
     while($result = mysql_fetch_array($row1)) {
     	if ($count==1){
?> <tr onMouseOver="this.style.cursor='hand'" BGCOLOR="#336699" VALIGN="MIDDLE">
<?php } ?>
<td CLASS="text" onClick="document.location.href='viewproduct.php?id=<? echo $result['id']; ?>'"> <p><font color=#ffcc00><b> <br> <br> <? echo($result['title']); ?> 
</b></font><br /><br /> <img style="float:left;" src="<? echo($result['imgname']); ?>" HSPACE="10"/> 
<?echo(nl2br($result['info_short']));?> </p><p align="left"><br> </p>
<?php
$count++;
if ($count==3){ ?>
<div align="center"> 
<p> </p></div></td></tr> <tr><td><div align="center"><img src="/images/yellowbar.gif" width="600" height="1"></div></td></tr> 
<? }} ?> <tr><td class="text" align="center"> </td>
</tr> 
</table></td><td valign="top"><IMG SRC="images/cleardot.gif" WIDTH="20" HEIGHT="1"></td><td valign="top"> </td></tr> 
<tr VALIGN="MIDDLE" ALIGN="CENTER"><td> </td><td><br /> </td><td> </td><td> </td></tr> 
</table><TD VALIGN="TOP" ><table> <tr><td><img src='cleardot.gif' width="1" height='7'><div id='travelmenu' style='position:relative; width:140; height:300;'><img src='cleardot.gif' width='138' height='100'></div></ 
br><img src='cleardot.gif' width="1" height='40'> </td></tr> </table></TD></tr> 
</table><br> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"> <tr BGCOLOR="#979797"> 
<td COLSPAN="14" HEIGHT="1"></td></tr> <tr BGCOLOR="#585858"> <td COLSPAN="13" HEIGHT="20" CLASS="nav" bgcolor="#336699" align="left">     Copyright 
© 2006 - 2010 Family Travel   </td><td HEIGHT="20" CLASS="nav" bgcolor="#336699" align="right">   </td></tr> 
<tr BGCOLOR="#979797"> <td COLSPAN="14" HEIGHT="1"></td></tr> </table>

<!-- IndexTools Customization Code -->
<!-- Remove leading // to activate custom variables -->
<script language="Javascript">
//var DOCUMENTGROUP='';
//var DOCUMENTNAME='';
//var ACTION='';
</script>
<!-- End of Customization Code -->
<!-- IndexTools Code v4.00 - All rights reserved -->
<script language="javascript1.1" src="http://www.familytravel.co.nz/indextools.js"></script><noscript>
<img src="http://stats.indextools.com/p.pl?a=1000629694096&js=no" width="1" height="1"></noscript><!--//-->
<!-- End of IndexTools Code -->

</body>

</html>

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.