Jump to content

Recommended Posts

Hi All,

 

I am trying to output some information from my sql database, I need to output three customers per row each in their own column (cell) and then after the 3rd customer start a new row etc etc.

 

I have the following code but there is a syntax error and i can't seem to find it, can someone point me the right direction.

 

<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr class="headercolour">
    <td width="37%"><div align="center">
      <div align="left">><? echo $col1; ?></div>
    </div></td>
    
    <td width="39%"><div align="center">
      <div align="left"><? echo $col2; ?></div>
    </div></td>
    
    <td width="16%"><div align="center">
      <div align="left"><? echo $col3; ?></div>
    </div></td>
    </tr>
<?
i = 0;
while ($row = mysql_fetch_assoc($result))
{
if ($i == 0)
{
?>
<tr class="tr" onMouseOver="h(this)" onMouseOut="n(this)">
<?php } else { ?>
    <td><? echo $row['customername']; ?>test</td>
<?php
}
else ($i == 2)
{
	$i = 0;
?>
    </tr>
<?php
}
$i++;
}
?>
</table>

Thank you for your quick reply;

 

the $col variables where passed through from a different page using the post method, but I have now removed these. I do not recieve an error when running the page only that the page doesn't display anything.

 

Sam

try

<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr class="headercolour">
    <td width="37%"><div align="center">
    <div align="left">><? echo $col1; ?></div>
    </div></td>
    
    <td width="39%"><div align="center">
    <div align="left"><? echo $col2; ?></div>
    </div></td>
    
    <td width="16%"><div align="center">
    <div align="left"><? echo $col3; ?></div>
    </div></td>
    </tr>
<?
i = 0;
while ($row = mysql_fetch_assoc($result))
{
if ($i++ == 0)
{
?>
<tr class="tr" onMouseOver="h(this)" onMouseOut="n(this)">
<?php    
           }  
?>
    <td><? echo $row['customername']; ?>test</td>
<?php if($i==3)	
           {
$i = 0;
?>
    </tr>
<?php
}
}
?>
</table>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.