Problem with if statement and while loops
| From: | Steve Buehler | Date: | Fri, 24 May 2002 17:29:11 +0000 |
| Subject: | Problem with if statement and while loops | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-99111@lists.php.net to get a copy of this message | ||
I am having trouble with the following function. What it should do is to check one table for team_id's. Than it goes to another table and gets all rows with that team_id. If the team_id is in the new table, it should do one thing, else it should do something else. Can somebody look at this code and see if they can find out where my problem is besides in my inexperience? It always goes to the else statement inside the if statement.
function searchbyteamname($team_name){
GLOBAL $PHP_SELF;
$result=mysql_query("SELECT team_id,name FROM team WHERE name like '%$team_name%' AND deleted NOT LIKE '1' ORDER BY 'name'");
$i=1;
while (($row=mysql_fetch_object($result))){
if(!($result1=mysql_query("SELECT * FROM team_season WHERE team_id = '$row->team_id' AND deleted NOT LIKE '1'"))){
echo "$i. $row->name";
$i++;
}else{
while(($row1=mysql_fetch_object($result1))){
echo "$i. <a href=\"$PHP_SELF?action=edit&team_id=$row->team_id\">$row->name</a></td>";
echo getdivisionnameshort($row1->div_id);
echo getseasonnameshort($row1->sea_id)\n";
$i++;
}
}
}
}
Thank You In Advance
Steve