Re: Column Help Needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It seems very easy to me, Chris.

Just set up a counter before the loop where you fetch your queries.  Then
output your HTML table structure depending on whether the counter is odd
or even.  You can use modulo arithmethic ($value%2) to determine that.

Something like:

$result = mysql_query("blah blah blah...");
$num-entries = 0;
echo "<table>";
while ($item = mysql_fetch_array($result))
{
  $num-entries++;
  if ($num-entries%2 == 1)
  {
    // This is an "odd" item.
    echo "<tr><td>";
    echo "blah"; // Whatever you need to output for your result
    echo "</td>";
  } else {
    // This is an "even" item.
    echo "<td>";
    echo "blah"; // Whatever you need to output for your result
    echo "</td></tr>";
  }
}
// and finally, if the result ended on a half-row:
if ($num-entries%2 == 1)
  echo "<td>&nbsp;</td></tr>";
// now close the table.
echo "</table>";
// and we're done!

.... note, I didn't test this code.  But it should do what you want.

-- 
Peter Westergaard
peter@xxxxxxxxxxxxxx

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux