General Zone > The Lounge
Helping Roumlus to stop his prof calling him a noob tomorrow :D
-Adler-:
https://pastebin.com/URfWjXJf
bell spark mips test
Yes:
Hi All,
Got bored took a look
CSS classes would be best practise but aren't fully nessesary if you don't want to
I've made a function that I THINK does what your looking for
--- Code: ---function kepre($tomb){
$tipp=array(0,1,2,3,4,5);
$table = "";
//print_r($tomb); use this to print
$table.="<table border=\"2\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" >\n";
for ($i=1; $i<91; $i++)
{
$table.="<font size=\"6\">";
if(in_array($i, $tipp)){
//echo "i be: $i";
if($tomb[$i] == 1){
$table.="<td bgcolor=\"#FF0000\">";
}
else{
$table.="<td bgcolor=\"#47FF00\">";
}
}
else
$table.="<td bgcolor=\"#eeeeee\">";
$table.=$i;
$table.="</td></font>"; // never closed your td tag
if($i%15==0)
{
$table.="<tr>\n";
}
}
$table.="</table>\n";
echo $table;
return true;
}
--- End code ---
I got confused at first so the $table syntax probably isn't needed
Effectivelly though $tomb ended up being something like this:
--- Code: ---Array ( [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] => 0 [16] => 0 [17] => 0 [18] => 0 [19] => 0 [20] => 0 [21] => 0 [22] => 0 [23] => 0 [24] => 0 [25] => 0 [26] => 1 [27] => 0 [28] => 0 [29] => 0 [30] => 0 [31] => 0 [32] => 1 [33] => 0 [34] => 0 [35] => 0 [36] => 1 [37] => 0 [38] => 0 [39] => 0 [40] => 0 [41] => 0 [42] => 0 [43] => 0 [44] => 0 [45] => 0 [46] => 0 [47] => 0 [48] => 0 [49] => 0 [50] => 0 [51] => 0 [52] => 0 [53] => 0 [54] => 0 [55] => 0 [56] => 0 [57] => 0 [58] => 0 [59] => 0 [60] => 0 [61] => 0 [62] => 0 [63] => 0 [64] => 0 [65] => 0 [66] => 0 [67] => 0 [68] => 0 [69] => 0 [70] => 0 [71] => 0 [72] => 0 [73] => 0 [74] => 0 [75] => 1 [76] => 0 [77] => 0 [78] => 0 [79] => 0 [80] => 1 [81] => 0 [82] => 0 [83] => 0 [84] => 0 [85] => 0 [86] => 0 [87] => 0 [88] => 0 [89] => 0 [90] => 0 )
--- End code ---
So e.g. 26 in this example was 1 meaning it was one of your numbers
All you really have to do is compare that in your loop and print out accordingly
So basically in terms of the changes I made (didn't need too many)
* $table to serve as the output - this wasn't really nessessary tbh but I couldn't be bothered replacing it. Can replace the $table.= with your prints again if needbe
* Closed your td cell; most browsers help with this anyway but good to know -> $table.="</td></font>";
* Replaced your if($tipp[1]==$i || $tipp[2]==$i || $tipp[3]==$i || $tipp[4]==$i || $tipp[5]==$i) with if(in_array($i, $tipp)){ - check here for details: https://www.w3schools.com/php/func_array_in_array.asp but tl;dr it'll just check if I is in your tipp array
* Then the main part, from what it sounded like you only wanted it red in the first 5 so I just whacked an if/else inside if($tomb[$i] == 1){
$table.="<td bgcolor=\"#FF0000\">";
}
else{
$table.="<td bgcolor=\"#47FF00\">";
}
Gives you something like
Romulus:
Okay......redesign ...
I'm done with so many minor errors that I ask for the numbers and the machine doesn't generate a random 5 number ... but whichever number I'm guessing will be red ... see the picture.
https://ibb.co/SvnyxMs
https://ibb.co/XFYPQhq
-Adler-:
https://pastebin.com/URfWjXJf
bell spark mips test
//VARS
$MyLottoTipp = array(1,10,20,30,40,50);
$LottoRandomNumbers = generateRandom();
echo '<h2>Lotto-Numbers</h2>';
displayLottoList($LottoRandomNumbers,'Number: ');
echo '<h2>Lotto-Tipps</h2>';
displayLottoList($MyLottoTipp,'Tipp: ');
displayLottoTable($LottoRandomNumbers,$MyLottoTipp);
Romulus:
.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version