Changing Colours In PHP -


the following couple of code snippets basic php. decided add alternating row colours make things bit clearer. problem have whatever set colour values rows alternate between dark red , fuchsia background. happens on both windows , linux , cannot understand why?

$row_count = 1; // track rows //$colour_odd = "#ffe680"; $colour_odd = "f0ffff"; //$colour_even = "#fff2bf"; $colour_even = "00ffff";  while ($row = mysql_fetch_assoc($result)) {     $row_colour = (($row_count % 2) == 0) ? colour_even: colour_odd;     echo '         <tr bgcolor="' . $row_colour . '">             <td width="150" align="center">' . $row['firstname'] . '</td>             <td align="center"><a href="' . $row['lastname'] . '">' .$row['lastname'] . '</a></td>          </tr>';     $row_count++; } 

putting comment answer:

colour_even: colour_odd treated constants. forgot $ signs.

using error reporting have told "undefined constant colour_even..." etc.

modify read as: $colour_even: $colour_odd;

add error reporting top of file(s) find errors.

<?php  error_reporting(e_all); ini_set('display_errors', 1);  // rest of code 

sidenote: error reporting should done in staging, , never production.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -