The table I want to condition does not repeat itself. Rows within it do, but those I got under control.
Now, the table (simplified) looks like this:
Code:
First row (has the headers of each field: Id, Manufacturer, Model, Year, Price and Img thumbnail)
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr align="left">
<td width="50" scope="col"><h4><?php if ($rows_conteo_prod <= 0) { echo "Actualmente no hay productos existentes en esta categoría";} else {echo "Siitto_ID";} ?></h4></td>
<td width="30" height="30" align="center" scope="col"> </td>
<td scope="col"><h4><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo "Marca";} ?></h4></td>
<td scope="col"> </td>
<td scope="col"><h4><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo "Modelo";} ?></h4></td>
<td scope="col"> </td>
<td scope="col"><h4><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo "Año";} ?></h4></td>
<td scope="col"> </td>
<td scope="col"><h4><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo "Precio";} ?></h4></td>
</tr> Ends first row, starts second row with the actual content and the php code that makes that content row repeat itself.
<?php do { ?>
<tr bgcolor="<?php if ($rowcolor == "#FFFFFF") { $rowcolor = "#CCCCCC" ; } else {$rowcolor = "#FFFFFF" ;} {echo $rowcolor;} ?>">
<td width="50" align="left" scope="col" > <a href="inv_detalle.php?siittoID=<?php echo $row_lista_main['mont_ID']; ?>"><?php echo $row_lista_main['mont_ID']; ?></a></td>
<td width="30" height="30" align="center" scope="col"><img src="<?php if ($row_lista_main['img_url1'] = "Imagenes/p.gif") {echo "Imagenes/blank.gif"; } else {echo $row_lista_main['img_url1']; } ?>" height="30" width="30"></td>
<td align="left" scope="col"><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo $row_lista_main['marca_name'];} ?></td>
<td scope="col"> </td>
<td align="left" scope="col"><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo $row_lista_main['modelo'];} ?></td>
<td scope="col"> </td>
<td align="left" scope="col"><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo $row_lista_main['year'];} ?></td>
<td scope="col"> </td>
<td align="left" scope="col"><?php if ($rows_conteo_prod <= 0) { echo "";} else {echo "$".$row_lista_main['precio'];} ?></td>
</tr>
Ends row and then comes the 'while' for the 'do' function.
<?php } while ($row_lista_main = mysql_fetch_assoc($lista_main)); ?>
Ends the table
</table>
What the little pieces of PHP code inside the header and content rows do is basically show themselves if there are products, or show nothing if there's nothing to be shown (0 products).
What comes up when there are no products is a single message that reads "There are currently no products in this category".
But since the rows are still there, it appears all scrambled.
By conditioning the generation of the table itself, I can go for a clean "No products" message with no hassle.
Now, several things come to mind:
1- How do I stop the php openining and closing tags to interfere with the string of html code to be put inside the echo's ""??
2- Regardless of #1 being doable, if I can condition the generation of the whole table itself, I could remove the conditioning part of the php code inside the table, but not the echoing of the dynamic values, so...
I hope myself a little bit more clear =/