Code:
<tr valign="top">
<td bgcolor="$row_color" ><?php echo $qry['FirstName']; ?></td>
<td bgcolor="$row_color"><?php echo $qry['LastName']; ?></td>
<td bgcolor="$row_color"><?php echo date('d/m/Y', strtotime($qry['DateOfBirth'])); ?></td>
<td bgcolor="$row_color"><?php echo($qry['loginDateTime']?date('d/m/Y H:i:s', strtotime($qry['loginDateTime'])):'N/A'); ?></td>
<td bgcolor="$row_color"><?php echo $qry['State'];?></td>
<td bgcolor="$row_color"><?php echo $q['Name'];?></td>
</tr>
I am guessing that if you look at the source code you will see <td bgcolor=$row_color ...
this is because you have stopped the transmission of php. now you can either do <?php echo "" ?> for every single one of those or you could modify the script so you just parse it all in, and escape to php for your variable.
Code:
...
else {
while ($qry = mysql_fetch_array($info)) {
$rep = $qry['rep_NBR'];
$repInfo = mysql_query("SELECT * FROM `tblrepresentatives` WHERE `rep_NBR`='$rep'");
$q = mysql_fetch_array($repInfo);
$row_color = ($row_count % 2) ? $color1 : $color2;
//create the layout
echo ' // Starts Output
<link href="cs_style.css" rel="stylesheet" type="text/css" />
<tr valign="top">
<td bgcolor="' . $row_color . '">' . $qry['FirstName'] . '</td>
<td bgcolor="' . $row_color . '">' . $qry['LastName'] . '</td>
<td bgcolor="' . $row_color . '">' . date('d/m/Y', strtotime($qry['DateOfBirth'])) . '</td>
<td bgcolor="' . $row_color . '">' . $qry['loginDateTime']?date('d/m/Y H:i:s', strtotime($qry['loginDateTime'])):'N/A') . '</td>
<td bgcolor="' . $row_color . '">' . $qry['State'] . '</td>
<td bgcolor="' . $row_color . '">' . $q['Name'] . '</td>
</tr>
'; // Ends Output
$row_count++;
}
}
echo '</table>';
?>
HTML supports both single and double quoted strings, so it is possible to do it this way, the other alternative, would be to backslash ( \ ) escape all of the double quotes that are intended to be html based.
It also might just be easier instead of coloring all the data cells, just to color the entire row ? then you wouldn't need the background color for all of the datacells.
Code:
echo ' // Starts Output
<link href="cs_style.css" rel="stylesheet" type="text/css" />
<tr valign="top" bgcolor="' . $row_color . '">
If you only have a couple of rows to do this on it won't be too much of a hassle, however if you have like 1000+ adding 1-2kb extra each ? thats alot of transfer that will take longer to download for the user?
...just a thought
Bookmarks