just wondered if someone could help get my code working.
I have a database set up of fixtures and results for a local club.
On the php page the fixtures list is populated from this table in the database with alternating background colours. This works great. however we would like to have the links for the results automatically added when we upload them to the database.
I have the below code that sets out the alternating colours and also puts the link on the text, howeve, this adds links to all the fixtures but if there is no link specified in the database then it loops back to the page.
How can I make it so that there is an if statement inside the echo, so that the <a> is only applied to this if results field is not blank.
Here is my current code:
***** Please wrap code in
Code: Select all
tags. *****Code: Select all
<?php
while($rows=mysql_fetch_array($result)){
if($color==1){
echo "<tr class='rowA'>
<td> </td>
<td>$rows[day]</td>
<td>$rows[date]</td>
<td><a href='$rows[results]' target='_blank'>$rows[fixture]</a></td>
<td>$rows[venue]</td>
</tr>";
$color="2";
} else {
echo "<tr class='rowB'>
<td> </td>
<td>$rows[day]</td>
<td>$rows[date]</td>
<td><a href='$rows[results]' target='_blank'>$rows[fixture]</a></td>
<td>$rows[venue]</td>
</tr>";
$color="1";
}
}
mysql_close();
?>