Jump to content

alternating error


user4fun

Recommended Posts

I use this to alternate the background color, unfortuantly with the tabe structure rowspan it is not working right

IF (mysql_num_rows($result) >= 1) {echo " <div align='center'><table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse'  width='90%'><tr><th>Picture</th><th>Information</th></tr>";$alt = true;while($row = mysql_fetch_array($result))  	 {if ($alt)	echo "<tr bgcolor=\"#F2F2F2\">";  else	echo "<tr bgcolor=\"#F1F1E4\">";  $alt = !$alt;echo "<td width='120' height='100' rowspan='2'><img src=".$row["Pic_Link"]." width='120' height='100'/></td>";echo "<td align='left' valign='top' height='5'><b><font face='Arial Unicode MS' color='#768E14'><b>" . $row['Price'] . "</b></td>";echo "<td td align='left' valign='top' height='5'><a href=\"../more_info.php?ID=".$row['ID']."\" target=\"_blank\">Get Detailed Info</a></td></tr>";echo "<tr><td colspan='2' align='left' valign='top' height='110'>" . $row['Discription'] . "</td>"; echo "</tr>";  	 }echo "</table>";}else{echo "Sorry, there are no litems at this time";}

Link to comment
Share on other sites

Your php code is OK. The problem is that the colors you have chosen for the backgrounds aren't strong enough to make any difference.To test it change the first one to #FF0000 (bright red) and the second to #00FF00 (green). You will see the alternating row colours.

Link to comment
Share on other sites

Since each independent $row that gets picked will be diplayed over two table rowsmy alternating colors are showing$row 1First row $row1 is one colorSecond for for $row1 is another colorWhat i need is$row 1First row $row1 is one colorSecond for for $row1 is the same colorThenIt will alternate for $row2If that does not make it clear, I think i am going to just make a <br>for each $row instead of having two rowsso it will be1 td for picanother td for the other stuff then <br>for the discription information then the </td>It will be one row with two colums instead of one row row span 2 and another colomn with two rowsTHIS IS A MESS lol

Link to comment
Share on other sites

If you are going to use tables then having a <br /> within a td cell will help. Another way would be to repeat theif ($alt) statements when you start the second tr further down and don't have $alt=!$alt until after the second tr has been created.$alt = true;while ......{if ($alt) create 1st tr with colour 1; else create 1st tr with colour 2;.... your td stuff for the first row goes hereif ($alt) create 2nd tr with colour 1; else create 2nd tr with colour 2;.... your td stuff for the second row goes hereTHEN YOU CAN HAVE $alt = !$alt}By the way, in one of your echo lines near the bottom you have <td td align='left'... needs fixed.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...