Jump to content

Recommended Posts

Hi

 

I have a table that populated by a recordset, and wondered whether is was possible to make a row background colour = red where a particular cell = some text?

 

I have been searching around and not managed to find anything of use.

 

Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/248961-conditional-format-cell-colour-on-table/
Share on other sites

Thanks for the code, I have not had a go as yet, but I'm going to try adding it to the following table code:

 

<table width="728" border="1">

  <tr>

    <td>id</td>

    <td>value</td>

  </tr>

  <?php do { ?>

    <tr>

      <td><?php echo $row_Recordset1['id']; ?></td>

      <td><?php echo $row_Recordset1['Value']; ?></td>

    </tr>

    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

</table>

hi, ok, made some inroads, but the formatting comes out off, in that the columns dont align for some reason, but I made code look like this and it works:

 

<table width="468" border="1">

  <tr>

    <td width="287">id</td>

    <td width="165">value</td>

  </tr>

  <?php do { ?>

    <tr>

      <td><?php echo $row_Recordset1['id']; ?></td>

      <td><?php echo "<td style='background-color: " . ( $row_Recordset1['Value'] == 1 ? 'red' : 'white' ) . ";'>{$row_Recordset1['Value']}</td>"; ?></td>

     

    </tr>

    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

</table>

 

 

 

Can anyone suggest how to make the table align? Also, what about multiple criteria e.g. 1 = red, 2 = blue, 3 = green etc etc.....?

 

[attachment deleted by admin]

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.