[Project]
A simple 6/45 Lotto number generator using web interface

[Board]
P4S-342

[Explanation]

a. The numbers are chosen at random using the rand() function.
b. Select 6 numbers that do not duplicated with one another.
c. Output the 6 numbers arranged in the ascending order.
d. Apply text colors classified with each number.

[Screen Shot]
Click image for larger version

Name:	lotto.PNG
Views:	849
Size:	36.3 KB
ID:	186


[Source Codes - index.php]

PHP Code:
<?php

$num_arr 
= array(000000);

// getting 6 numbers without duplication
for($i 0$i 6$i++)
{
    
$num rand(145);
    if(
$i != 0)
    {
        for(
$j 0$j $i$j++)
        {
            if(
$num == $num_arr[$j])
            {
                
$i--;
                continue 
2;
            }
        }
    }
    
$num_arr[$i] = $num;
}

// bubble sort
for($i 0$i 5$i++)
{
    for(
$j 0$j 5$j++)
    {
        if(
$num_arr[$j] > $num_arr[$j+1])
        {
            
$temp $num_arr[$j];
            
$num_arr[$j] = $num_arr[$j+1];
            
$num_arr[$j+1] = $temp;
        }
    }
}

?>

<html>
<body bgcolor="lightgrey">
<center>

<h1>Your Lucky Numbers!</h1>

<table align="center" cellpadding="5">
<tr>
<?php
for($i 0$i 6$i++)
{
    if(
$num_arr[$i] <= 10)
        echo 
"<td bgcolor=#FFEE99><font size="26">";
    elseif(
$num_arr[$i] <= 20)
        echo 
"<td bgcolor=#9EACFF><font size="26">";
    elseif(
$num_arr[$i] <= 30)
        echo 
"<td bgcolor=#FFA3A3><font size="26">";
    elseif(
$num_arr[$i] <= 40)
        echo 
"<td bgcolor=#C0C0C0><font size="26">";
    elseif(
$num_arr[$i] <= 45)
        echo 
"<td bgcolor=#C2FFA8><font size="26">";
    
printf("%02d"$num_arr[$i]);
    echo 
"</font></td>";
}
?>
</tr>
</table>

<p>
<a href="index.php">Refresh</a>
</p>

</center>
</body>
</html>