| Uutiset | Koodikirjasto | Wiki | Keskustelut | FAQ | Info |
Lottorivin arpojaJ0p3 04.01.03 19:03 Arpoo 7 eri numeroa 1:n ja 39:n väliltä ja laittaa ne järjestykseen ja tulostaa html taulukkoon.
<?php //Tämä lottoarpoja arpoo seitsemän eri satunnaista lukua ja laittaa ne järjestykseen. //Kenties aika turha ohjelma, mutta tässä se nyt kuitenkin on. $old = array(); while(count($old) < 7) { $num = rand(1,39); $add = "yes"; for($i=0;$i<count($old);$i++) { if($old[$i] == $num) { $add = "no"; } } if($add == "yes") { array_push($old, $num); } } sort($old); ?> <html> <head> <title>Lotto</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <style type="text/css"> <!-- body { font-family: Arial; font-size: 14px; color: #000000; text-decoration: none; background-color: #BABABA; } --> </style> <style type="text/css"> <!-- .1 { font-family: Arial; font-size: 12px; font-weight: bold; color: #000000; text-decoration: none; background-color: #CCCCCC; text-align: center; vertical-align: middle; padding: 3px; border: 1px solid #000000; width: 18px; } .2 { font-family: Arial; font-size: 12px; font-weight: bold; color: #000000; text-decoration: none; background-color: #CCCCCC; text-align: center; vertical-align: middle; padding: 3px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 0px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; width: 18px; } .a1 { font-family: Arial; font-size: 12px; color: #000000; text-decoration: none; background-color: #CCCCCC; text-align: center; vertical-align: middle; padding: 3px; border: 1px solid #000000; font-weight: bold; } .a2 { font-family: Arial; font-size: 13px; color: #000000; text-decoration: none; background-color: #FFFFFF; text-align: center; vertical-align: middle; padding: 3px; border-top-width: 0px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 0px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; } --> </style> </head> <body> <h2><font color="#333333">Lottorivin arpoja</font></h2> <table width="0" border="0" cellspacing="0" cellpadding="0"> <tr> <td></td> <td class="1">1</td> <td class="2">2</td> <td class="2">3</td> <td class="2">4</td> <td class="2">5</td> <td class="2">6</td> <td class="2">7</td> </tr> <tr> <td class="a1">Numerot:</td> <td class="a2"><?php print($old["0"]); ?></td> <td class="a2"><?php print($old["1"]); ?></td> <td class="a2"><?php print($old["2"]); ?></td> <td class="a2"><?php print($old["3"]); ?></td> <td class="a2"><?php print($old["4"]); ?></td> <td class="a2"><?php print($old["5"]); ?></td> <td class="a2"><?php print($old["6"]); ?></td> </tr> </table> <br> <input type="button" name="Button" value="Arvo uudestaan" onClick="javascript:parent.location='<?php echo $PHP_SELF ?>'"> </body> </html> thefox 19:06 4.1.03 Mielenkiintoinen tapa käyttää merkkijonoa boolean-fläginä. Tulostuksen olisi kenties voinut hoitaa ihan arvontaloopissa, tai ainakin silmukalla. ane 20:38 4.1.03 Ihan naseva, mutta tyylisivuja voisi lyhentää. empty 23:02 4.1.03 örr.. tein ton scriptin foorumiin :P Vähän oot muutellu, mutta ei siinä mitää.. kolmonen sille _o/ J0p3 15:18 5.1.03 Joo pakko myöntää, vähän jopen avustuksela on väsätty... Sain muuten sen oman function workkimaan, joten voisin kohta laitella sen tohon niin on sitten ilman apuja tehty... empty 13:01 21.1.03 Joo no tosta Anzuhanin kommentista tuli mieleen, että noi borderit voi hoitaa ihan tyyliin: border-left: 1px solid #000000; border-right: 1px solid #000000; jne. :) |
![]() Haku
|