Question : PHP - No results show for If else statement

Experts,
Simple php question.  (see code below).
I have a list of Sports teams.  I am echoing them all out.
While each one is listed, I'm checking a "Picks" table to see if the user picked this team to win.

If they DID, it will echo the week that they picked the team.
If they Didn't, it should output "You did not chose this team!"

This correctly outputs if the user picked this team.
However, Nothing outputs in my ELSE statement.
It does not change the color or echo the line "You did not chose this team!"

How can my IF output work correctly, but I get nothing for the ELSE.
I also get NO syntax errors.  Nothing just shows for the ELSE.

Any ideas?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
$q4="select * from MLBTEAMS order by MLBFirst asc";
$r4=mysql_query($q4) or die(mysql_error());
while ($a4=mysql_fetch_array($r4)) {
echo "<TR Height=50>";
echo "<TD><center><img src=Logos/" . $a4[XMLID] . ".png width=35%></center></TD>";
echo "<TD><H3>" . $a4[MLBFirst] . " " . $a4[MLBLast] . "</H3></TD>";	
	

$q7="select * from PICKS where UserID='$_SESSION[UserID]' AND XMLID = '$a4[XMLID]'";
$r7=mysql_query($q7) or die(mysql_error());
while ($a7=mysql_fetch_array($r7)) 
{
	If($a7)
	{
	echo "<TD bgcolor='#FF6600'>Picked in Week: " . $a7[WeekNum] . "</TD>";
	}
	else {
	echo "<TD bgcolor='#00FF00'>You did not pick this team!</TD>";}
	}
		
	echo "</TR>";
	
}

Answer : PHP - No results show for If else statement

Have a look at this example (save it as a file and browse to it).

In your html, emit a hidden form value that gets set.
In each of the link that you produce, include the id in the _submit(<here>)
In the PHP, check that there is an ID, then you can use it.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
<?php
if ($_POST) {
    echo '<pre>';
    echo 'you chose ' . $_POST["teamid"];
    echo '</pre>';
}
?>
<script>
function _submit(teamid) {
document.form.teamid.value=teamid;
}
</script>
<form name="form" action="" method="post">
    <input type="hidden" name="teamid";>
    <input type="submit" value="Choose this team!" onclick="_submit(1)";>
    <input type="submit" value="Choose this team!" onclick="_submit(2)";>
    <input type="submit" value="Choose this team!" onclick="_submit(3)";>
</form>
Random Solutions  
 
programming4us programming4us