Anyways, i've got 2 questions. I want to add alternate table rows into my table. At the moment i've styled them with CSS <tr class='LightPink'> and <tr class='DarkPink'>. Is it possible to use those 2 as alternate's?
Also, as you can see below I have a header row in my table. How can I have it so that the header row will only be displayed if a result can be found in the table?
Here's the code:
<?php
echo "<table>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Size</th>";
echo "<th>Price</th>";
echo "<th>Delivery</th>";
echo "<th></th>";
echo "</tr>";
$sql = "
(SELECT * FROM `Table1` WHERE `product_name` LIKE '%XYZ%')
UNION
(SELECT * FROM `Table2` WHERE `product_name` LIKE '%XYZ%')
UNION
(SELECT * FROM `Table3` WHERE `product_name` LIKE '%XYZ%')
UNION
(SELECT * FROM `Table4` WHERE `product_name` LIKE '%XYZ%')
ORDER BY `price` ASC";
$result = mysql_query($sql);
$nums = mysql_num_rows($result);
if($nums > 0) //Check if there is a row (over 0 means there is)
{
while($row = mysql_fetch_array($result))
{
echo "<tr class='LightPink'>";
echo "<td>".$row['program_name']."</td>";
echo "<td>30ml</td>";
echo "<td>".$row['price']."</td>";
echo "<td>Delivery</td>";
echo "<td><a href=".$row['deeplink']."rel='nofollow'>Buy</a></td>";
echo "</tr>";
}
}
else {
echo "";
}
echo "</table>";
echo "</br>";
echo "</br>";
?>
Thanks!
This post has been edited by Lee_K: 20 January 2012 - 08:45 PM
Help



















