Layout of mySQL quary (again!)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • knoak

    #1

    Layout of mySQL quary (again!)

    Hi there,

    I have the following code:

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

    echo "<table>";
    $column = 0;
    while ($myrow = mysql_fetch_arr ay($result2)) {
    $TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
    if (!$column) echo "<tr >";
    echo "<td bgcolor=\"$TDco lor\">",$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
  • Jerry Gitomer

    #2
    Re: Layout of mySQL quary (again!)

    knoak wrote:[color=blue]
    > Hi there,
    >
    > I have the following code:
    >
    > $side1 = '#EFEFEF';
    > $side2 = '#DDDDDD';
    > $sideoffset = 0;
    >
    > echo "<table>";
    > $column = 0;
    > while ($myrow = mysql_fetch_arr ay($result2)) {
    > $TDcolor = ($sideoffset++ % 2) ? $side1 : $side2;
    > if (!$column) echo "<tr >";
    > echo "<td bgcolor=\"$TDco lor\">",$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...
    >[/color]

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

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

    and change:
    echo "<table>";

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



    Comment

    Working...