Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hey there folks,
just having a little problem with trying to separate content in my table for easy viewing. I'm sure I'm screwing something simple up, but I just can't seem to figure out what it is... When there is a match in the table, the code has no problem, but it seems that as soon as there is no match, the server gets stuck. Any ideas?Code: Select all
<link href="Stylesheet.css" rel="stylesheet" type="text/css">
<?php
//get PAS tires from table
$getPAS = "SELECT * FROM Table WHERE brand='$brand' AND cat='PAS' ORDER BY diameter ASC";
$getPASresult = mysql_query($getPAS) or die(mysql_error());
$rowsofPAS = mysql_num_rows($getPASresult) or die(mysql_error());
//display 'PAS' items from table
if($rowsofPAS>=1) {
echo "<table border=0 cellspacing=0 cellpadding=0 align=center>
<tr>
<td colspan=9 align=center valign=middle class=Header>---==: Table PAS :==---</td>
</tr>
<tr>
<td height=2 bgcolor=#000000 colspan=9></td>
</tr>
<tr>
<td width=2 height=25 bgcolor=#000000></td>
<td align=left bgcolor=#666666 class=BoldTextWhite> Item # </td>
<td width=2 bgcolor=#000000></td>
<td align=left bgcolor=#666666 class=BoldTextWhite> Tire </td>
<td width=2 bgcolor=#000000></td>
<td align=center bgcolor=#666666 class=BoldTextWhite> Qty. </td>
<td width=2 bgcolor=#000000></td>
<td align=right bgcolor=#666666 class=BoldTextWhite> Price </td>
<td width=2 bgcolor=#000000></td>
</tr>";
for ($i=0; $i <$rowsofPAS; $i++) {
$row = mysql_fetch_array($getPASresult) or die(mysql_error());
if($i % 2 == 0) {//if selection row is not even use no bgcolor
if($row[15]=="Y") {//if row's 'red' is 'Y' print line red
printf("<tr><td width=2 bgcolor=#000000></td>
<td align=left class=Red> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=left class=Red> %s%s%s%s%s %s %s %s %sply </td>
<td width=2 bgcolor=#000000></td>
<td align=center class=Red> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=right class=Red> $%s </td>
<td width=2 bgcolor=#000000></td></tr>", $row[0], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7], $row[8], $row[9], $row[10], $row[1], $row[11]) or die(mysql_error());
}
else {//if row's 'red' is not 'Y' print line normal
printf("<tr><td width=2 bgcolor=#000000></td>
<td align=left class=text> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=left class=text> %s%s%s%s%s %s %s %s %sply </td>
<td width=2 bgcolor=#000000></td>
<td align=center class=text> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=right class=text> $%s </td>
<td width=2 bgcolor=#000000></td></tr>", $row[0], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7], $row[8], $row[9], $row[10], $row[1], $row[11]) or die(mysql_error());
}
}
else {//if row to display is not even use bgcolor=#EFEFEF
if($row[15]=="Y") {//if row's 'red' is 'Y' print line red
printf("<tr><td width=2 bgcolor=#000000></td>
<td align=left bgcolor=#EFEFEF class=Red> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=left bgcolor=#EFEFEF class=Red> %s%s%s%s%s %s %s %s %sply </td>
<td width=2 bgcolor=#000000></td>
<td align=center bgcolor=#EFEFEF class=Red> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=right bgcolor=#EFEFEF class=Red> $%s </td>
<td width=2 bgcolor=#000000></td></tr>", $row[0], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7], $row[8], $row[9], $row[10], $row[1], $row[11]) or die(mysql_error());
}
else {//if row's 'red' is not 'Y' print line normal
printf("<tr><td width=2 bgcolor=#000000></td>
<td align=left bgcolor=#EFEFEF class=text> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=left bgcolor=#EFEFEF class=text> %s%s%s%s%s %s %s %s %sply </td>
<td width=2 bgcolor=#000000></td>
<td align=center bgcolor=#EFEFEF class=text> %s </td>
<td width=2 bgcolor=#000000></td>
<td align=right bgcolor=#EFEFEF class=text> $%s </td>
<td width=2 bgcolor=#000000></td></tr>", $row[0], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7], $row[8], $row[9], $row[10], $row[1], $row[11]) or die(mysql_error());
}
}
}//end $i loop
echo "<tr>
<td height=2 bgcolor=#000000 colspan=9></td>
</tr>
</table>";
}//end if($rowsofPAS>0)
else {
echo "No passenger tires to display";
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]