What I am trying to do is grab a set of winning lotto numbers from our database. These numbers are then
compared against a set of chosen numbers. Where the chosen number matches a picked number (from any draw),
the cell is turned blue. Here is the code I've written to take care of this task; it is not working as i expect. Could
somebody help me get it to do what i want? Thanks in advance.
/* Sets the SQL Query */
$sql = "SELECT * FROM picked WHERE num1 ORDER BY `date` ASC ";
$result = mysql_query($sql, $link);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
$array1 = array();
$a = 0;
//select drawn (winning numbers) 6 numbers for each draw
//and there are three draws in the database
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$array1[$a] = "$row[num1],$row[num2],$row[num3],$row[num4],
$row[num5],$row[num6]";
echo "<div class=\"fresh\">Draw (<strong>" . $a++ . "</strong>)
" . $row["date"] . "" . " " . $row["num1"] . " ,
" . $row["num2"] . " , " . $row["num3"] . " , " . $row["num4"]
. " , " . $row["num5"] . " , " . $row["num6"] . "<br>\n</div>";
}//end while
?>
// selects names and picked numbers
$sql = "SELECT * FROM `beck` WHERE 1 ORDER BY `names` ASC ";
/* Passes a Query to the Active Database */
$result1 = mysql_query($sql, $link);
if (!$result1) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
/* Starts the table and creates headings */
?>
<br>
<table width="90%" align="center" border="1" cellpadding="0" cellspacing="0">
<tr class="brtop">
<td width="6%">
<div align="center"><strong>#</strong></div></td>
<td width="14%">
<div align="left"><strong>Name</strong></div>
</td>
<td width="6%">
<div align="center"><strong>1</strong></div>
</td>
<td width="6%">
<div align="center"><strong>2</strong></div>
</td>
<td width="6%">
<div align="center"><strong>3</strong></div>
</td>
<td width="6%">
<div align="center"><strong>4</strong></div>
</td>
<td width="6%">
<div align="center"><strong>5</strong></div>
</td>
<td width="6%">
<div align="center"><strong>6</strong></div>
</td>
<td width="6%">
<div align="center"><strong>7</strong></div>
</td>
<td width="6%">
<div align="center"><strong>8</strong></div>
</td>
<td width="6%">
<div align="center"><strong>9</strong></div>
</td>
<td width="6%">
<div align="center"><strong>10</strong></div>
</td>
</tr>
<?
$testarray = array();
ksort($array1);
$count = count($array1) - 1;
echo("count: ($count)<br>\n");
$a = 1;
while ($row1 = mysql_fetch_array($result1, MYSQL_ASSOC) ) {
echo("<tr><td class=\"brclr\"> " . $a++ . ")</td>");
echo("<td class=\"brcaps\"> " . $row1[names] . "</td>");
for ($i=0; $i <= $count; $i++) {
$testarray = explode(",", $array1[$i]);
$bcount = count($testarray) - 1;
//echo("bcount: ($bcount)<br>\n");
for ($b=0; $b <= $bcount; $b++) {
if ($row1[one] == $testarray[$b]) {
$one = "<td class=\"pick\">$row1[one]</td>";
}//end if
else {
$one = "<td>$row1[one]</td>";
}//end else
if ($row1[two] == $testarray[$b] ) {
$two = "<td class=\"pick\">$row1[two]</td>";
}//end if
else {
$two = "<td>$row1[two]</td>";
}//end else
if ($row1[three] == $testarray[$b] ) {
$three = "<td class=\"pick\">$row1[three]</td>";
}//end if
else {
$three = "<td>$row1[three]</td>";
}//end else
if ($row1[four] == $testarray[$b] ) {
$four = "<td class=\"pick\">$row1[four]</td>";
}//end if
else {
$four = "<td>$row1[four]</td>";
}//end else
if ($row1[five] == $testarray[$b] ) {
$five = "<td class=\"pick\">$row1[five]</td>";
}//end if
else {
$five = "<td>$row1[five]</td>";
}//end else
if ($row1[six] == $testarray[$b] ) {
$six = "<td class=\"pick\">$row1[six]</td>";
}//end if
else {
$six = "<td>$row1[six]</td>";
}//end else
if ($row1[seven] == $testarray[$b] ) {
$seven = "<td class=\"pick\">$row1[seven]</td>";
}//end if
else {
$seven = "<td>$row1[seven]</td>";
}//end else
if ($row1[eight] == $testarray[$b] ) {
$eight = "<td class=\"pick\">$row1[eight]</td>";
}//end if
else {
$eight = "<td>$row1[eight]</td>";
}//end else
if ($row1[nine] == $testarray[$b] ) {
$nine = "<td class=\"pick\">$row1[nine]</td>";
}//end if
else {
$nine = "<td>$row1[nine]</td>";
}//end else
if ($row1[ten] == $testarray[$b] ) {
$ten = "<td class=\"pick\">$row1[ten]</td>";
}//end if
else {
$ten = "<td>$row1[ten]</td>";
}//end else
}//end for
echo($one);
echo($two);
echo($three);
echo($four);
echo($five);
echo($six);
echo($seven);
echo($eight);
echo($nine);
echo($ten);
}//end for
}//end while
echo("</table>\n");