Skip to main content
Known Participant
June 23, 2011
Question

mysql output modifications

  • June 23, 2011
  • 1 reply
  • 371 views

I am outputting my table data, and would like to modify it several ways.  One way is to check if the account status is set to 1, change the color to red and bold it.  also, i do not want to show the password field.  lastly, i would like to modify the table so that I can insert a Modify Account link.  here is what I have at the moment:

echo "<table border='3' cellpadding='5'><tr> <th>ID</th> <th>Name</th> <th>Username</th> <th>Password</th> <th>E-mail</th> <th>Account Activation</th> <th>Account Type</th> <th>Account Status</th> <th>Amount of Banwhitch Used</th> <th>Modify Account</th>";

for ($j = 0; $j < $rows; ++$j)
{
    $row = mysql_fetch_row($result);
    echo"<tr>";
    for ($k = 0; $k<9; ++$k)
    {
        echo "<td>$row[$k]</td>";
    }
    echo "</tr>";
}

echo "</table>";

thanks

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
June 26, 2011

future-architect wrote:

I am outputting my table data, and would like to modify it several ways.

Use conditional statements.

for ($j = 0; $j < $rows; ++$j)
{
    $row = mysql_fetch_row($result);
    echo"<tr>";
    for ($k = 0; $k<10; $k++)
    {
        // don't show password
        if ($k == 3) {
            echo "<td>******</td>";
        }
        // check status
        elseif ($k == 7 && $row[$k] == 1) {
            echo "<td style='color:red;font-weight:bold'>$row[$k]</td>";
        ]
        // create link
        elseif ($k == 9) {
            // create link using $row[0] (ID)
        }
        else {
            echo "<td>$row[$k]</td>";
        }
    }
    echo "</tr>";
}

Message was edited by: David_Powers amending code for password.

Known Participant
June 27, 2011

nevermind, got it to work

Message was edited by: future-architect