By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

Layout of mySQL quary (again!)

P: n/a
Hi there,

I have the following code:

$side1 = '#EFEFEF';
$side2 = '#DDDDDD';
$sideoffset = 0;

echo "<table>";
$column = 0;
while ($myrow = mysql_fetch_array($result2)) {
$TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
if (!$column) echo "<tr >";
echo "<td bgcolor=\"$TDcolor\">",$myrow["last"],"</td>";
if ($column) echo "</tr>";
$column = !$column;
}
if ($column) echo "<td></td></tr>";
echo "</table>";
This really works great, but my next problem is that collumns on
the left side, need another <td>$var</td> on their left, and
the ones on the right need it on the right, so the output would
look like:

_ _____ _____ _
|_|__x__|__x__|_|
|_|__x__|__x__|_|
|_|__x__|__x__|_|

I hope this is clear enough, and that anyone can help me...

Greetings knoakske
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
knoak wrote:
Hi there,

I have the following code:

$side1 = '#EFEFEF';
$side2 = '#DDDDDD';
$sideoffset = 0;

echo "<table>";
$column = 0;
while ($myrow = mysql_fetch_array($result2)) {
$TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
if (!$column) echo "<tr >";
echo "<td bgcolor=\"$TDcolor\">",$myrow["last"],"</td>";
if ($column) echo "</tr>";
$column = !$column;
}
if ($column) echo "<td></td></tr>";
echo "</table>";
This really works great, but my next problem is that collumns on
the left side, need another <td>$var</td> on their left, and
the ones on the right need it on the right, so the output would
look like:

_ _____ _____ _
|_|__x__|__x__|_|
|_|__x__|__x__|_|
|_|__x__|__x__|_|

I hope this is clear enough, and that anyone can help me...


Change:
echo "<td bgcolor=\"$TDcolor\">",$myrow["last"],"</td>";

To:
echo "<td></td><td>$var</td><td>",$myrow["last"],"</td><td></td>";

and change:
echo "<table>";

To:
echo "<table bgcolor=\"$TDcolor\">
and of course you will have to move the statement where you
define $TDcolor.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.