I have a set of nested while loops to compare to mysql queries to each other. Here is the code:
while($row = mysql_fetch_array($resultbat))
{
$drafted = 0;
while($crossedRow = mysql_fetch_array($crossedAnswer))
{
if($row['NAME'] == $crossedRow['name'])
{
$drafted = 1;
}
else
{
$drafted = 0;
}
}
if ($drafted == 1)
{
echo "<tr class='drafted' id='" . $row['NAME'] . "'>";
}
else if($n&1)
{
echo "<tr id='" . $row['NAME'] . "'>";
}else
{
echo "<tr class='alt' id='" . $row['NAME'] . "'>";
}
...}
In the $resultbat is a list of all players, and in the $crossedAnswer is a list of a few players that should be marked. For each player I want to see if they are in the $crossedAnswer list of players. If they are I want to mark the class of that html element to drafted.
Thanks in advance.
mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial. – Kermit Jan 15 '13 at 22:29