| Home  | Casa  | Hardware  | Networking  | Programmazione  | Software  | Domanda  | Sistemi  |   
Programmazione  
  • C /C + + Programming

  • Computer Programming Languages

  • Delphi Programming

  • Java Programming

  • Programmazione Javascript

  • PHP /MySQL Programmazione

  • Perl Programming

  • Python Programming

  • rubino Programmazione

  • Nozioni di base di Visual Programming
  •  
    Conoscenza Informatica >> Programmazione >> PHP /MySQL Programmazione >> Content
    PHP Tutorial Scratch Card
    Gratta e Vinci può illuminare la vostra giornata e vi darò un momento di divertimento . Se vi piacciono i gratta e vinci , forse il vostro sito potranno beneficiare di un gioco gratta e vinci . È possibile utilizzare PHP per creare questo piccolo gioco . PHP è un lato server HTML linguaggio di scripting incorporato che fornisce una vasta gamma di strumenti che consentono di creare applicazioni Web dinamiche . È possibile utilizzare PHP per creare applicazioni complesse che interagiscono con più database e decine di migliaia di utenti , in modo da creare un gioco gratta e vinci è relativamente facile. Istruzioni
    1

    connettersi al database MySQL per l'esecuzione di questo comando nel prompt dei comandi:

    mysql db_name

    Sostituire " db_name " con il nome del database e log con il tuo nome utente e password
    2

    Esegui questo pezzo di codice per aggiungere una nuova tabella e riempirlo con i campi del database .

    CREATE tABLE ` scheda ` ( `id` int ( 100 ) NOT NULL AUTO_INCREMENT , ` nome ` varchar ( 200 ) NOT NULL default'' , ` soldi ` bigint ( 255 ) NOT NULL di default '0 ' , PRIMARY KEY ( `id` ) ) ENGINE = MyISAM AUTO_INCREMENT = 6 DI DEFAULT CHARSET = latin1 AUTO_INCREMENT = 6;

    È possibile copiare e incollare questo codice alla riga di comando di MySQL
    3

    Creare una nuova pagina Web PHP utilizzando questo codice : < . br>

    < DOCTYPE HTML PUBLIC " - //W3C //DTD XHTML 1.0 Transitional //EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " ,> < meta http-equiv = contenuto "Content-Type " = "text /html ; charset = utf- 8 " /> Scratch Card < /title> < /head> <body> < if ( isset ( $ _POST [ 'nuovo' ] ) ) {if ( ereg ( ? ' [ ^ A- Za - z0 - 9 ] ' , $ _POST [ 'name' ] ) ) { echo " nome non valido solo è consentito AZ, az e 0-9 . ";} else { $ sql = " INSERT INTO SET carta id = '' , denaro = '100000 ' , nome = ' " mysql_real_escape_string ( $ _POST [ 'name' ] ) . " '". ; $ res = mysql_query ( $ sql ) ; echo" <meta http-equiv=\\"refresh\\" content=\\"0;URL=scratch_card.php\\"> " ; ? > < table width = " " border = " 411 1 " align = " center " > <tr> <td colspan="2" align="center"> Inizia una nuova partita di Scratch Card < /td > < /tr> <tr> ; <td width="102"> Scegli un nome < /td> <td width="293"> < name = ingresso di tipo "nome" = classe "testo" = " entryfield " , id = "nome" style = 'width : 98 % ; ; border : 1px solid # 000000 ; font-size : 10px ; font-family : Verdana ; width: 98 % ; ' maxlength = " 20 " /> < /td > < /tr> <tr> <td colspan="2" align="right"> < name = ingresso di tipo "carta " class = " submit " = " pulsante " id = " carta " onfocus = " se " value =" ( this.blur ) this.blur ( ) Start " /> < /td > < /tr> < /table> < ;/body> < /html > <br> <p> Salva la pagina come " new_game.php . " Questa pagina consente agli utenti di iniziare una nuova partita . Si può utilizzare una casella di testo per inserire i loro nomi . Il campo del nome interagisce con il database , in modo da poter tenere traccia dei tuoi giocatori . <br> 4 <p> Creare un'altra pagina Web PHP che apparirà dopo che la pagina " new_game.php " . Usa questo codice per la seconda pagina : <br> <p> echo " <meta http-equiv=\\"refresh\\" content=\\"0;URL=scratch_card.php\\"> " ; <form method="post"> < php $ buy = $ _POST [' comprare '] ; ? $ sql = mysql_query ( "SELECT * FROM scheda WHERE nome = ' $ name' "); $ prendere = mysql_fetch_object ( $ sql ) ; $ card1 = rand ( 1,3) ; $ card2 = rand ( 1,3) ; $ DISP1 = "default" ; $ DISP2 = "default" ; if ( $ go ) { /////verificare se gli utenti hanno abbastanza soldi per visualizzarloIf ( $ fetch- > soldi > = " 10000" ) { $ nuovo = $ fetch- > money- 10000; mysql_query ( "UPDATE scheda SET soldi = ' $ nuovo ' WHERE nome = ' $ name' ");} else { print" non hai abbastanza soldi per comprare un gratta e vinci . " ; exit (); ! } < DOCTYPE HTML PUBLIC " ;-//W3C //DTD XHTML 1.0 Transitional //EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " > < html xmlns = " http : //www.w3.org/1999/xhtml " > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title> Scratch Card < /title> < /head> <body> < table width = confine " 400 " = " 0 " align = cellpadding " centro " cellspacing = " 0 " = " , 2 " class = " tavolo " > <tr> <td class="head"> <div> carta di Scratch < /div > < /td > < ;/tr> tr td <div> < /div > <div> < /div > < div align = " , " class = " center cella " > Prova le tue probabilità e provare il nostro gioco gratta e vinci < /div > < /td > < /tr> <tr> < td height = " " class = " 131 ; cella " > <div> <p> Aggiungi un'immagine qui se vuoi < /p> <p class="cell" > Premi : < /p > < ; ul > <li class="cell"> $ 100.000 < /li> < /ul > <p> < ? print " $ messaggio"; ? > < /p> <form method="post" action=""> < input type = valore " nascosto" = "andare" name = "andare" > < input type = classe " submit " value = " submit " = "Acquista un gratta e vinci per la seconda pagina PHP " scratch_card.php . " Si noti che questa pagina contiene sia il codice PHP per gestire il gioco gratta e vinci e il codice HTML per controllare il layout e le funzionalità della pagina web . <br> 5 < p > Carica le due pagine al tuo sito web e aggiungere un collegamento nella home page di " new_game.php . " Il gioco gratta e vinci è pronto ad intrattenere i vostri utenti . <br> <br> <div class=ad2><script language='javascript' src='/ad/201310/4.js'></script></div> </div> </td> </tr> </table> <table width="95%" height="1" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#DEE7EE"> <tr> <td></td> </tr> </table> <table width="100%" height="7" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table width="91%" height="52" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="51%"><p>Previous : <a class='LinkPrevArticle' href='/Programmazione/php-mysql-programming/91659.html' >Come disattivare clustering in MySQL </a></li></p></td> </tr> <tr> <td width="49%"> next : <a class='LinkNextArticle' href='/Programmazione/php-mysql-programming/91661.html' >Come utilizzare FBML Tags </a></li></td> </tr> </table></td> </tr> </table> <table width="100%" height="7" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table width="770" height="246" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="375" height="246" valign="top"><table width="380" border="0" cellpadding="0" cellspacing="0" class="bian"> <tr> <td height="244" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="img_dm/danmai_r4_c04 -.jpg" bgcolor="#DBE3EE"> <tr> <td width="4%" height="29"> </td> <td width="96%" class="lan_lm"> Articoli Correlati </td> </tr> </table> <table width="95%" height="209" border="0" align="center" cellpadding="0" cellspacing="4"> <tr> <td height="201"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91469.html" title="Conte PHP a MySQL Risultati " target="_self">Conte PHP a MySQL Risultati </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92138.html" title="Come creare PHP Contact Form con campi " target="_self">Come creare PHP Contact Form con campi </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92511.html" title="Formazione online per PHP Web Design " target="_self">Formazione online per PHP Web Design </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91312.html" title="PHP Fatal Error : Cannot Annullare l'impostazione offset delle stringhe " target="_self">PHP Fatal Error : Cannot Annullare l'impostazione offse…</a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91657.html" title="PHP Unlink Funzione " target="_self">PHP Unlink Funzione </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/91751.html" title="Come avviare Mysql in Linux " target="_self">Come avviare Mysql in Linux </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92392.html" title="Come eliminare le matrici di valore in PHP " target="_self">Come eliminare le matrici di valore in PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92821.html" title="Come riprodurre un file audio in PHP " target="_self">Come riprodurre un file audio in PHP </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92921.html" title="Come costruire un database per il sito Web " target="_self">Come costruire un database per il sito Web </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/php-mysql-programming/92995.html" title="Come convertire accesso a un server MySQL remoto " target="_self">Come convertire accesso a un server MySQL remoto </a></td></tr><tr></tr></table></td> </tr> </table></td> </tr> </table></td> <td width="20" valign="top"></td> <td width="375" valign="top"><table width="380" border="0" cellpadding="0" cellspacing="0" class="bian"> <tr> <td height="244" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="img_dm/danmai_r4_c04 -.jpg" bgcolor="#DBE3EE"> <tr> <td width="4%" height="29"> </td> <td width="96%" class="lan_lm">Articoli in evidenza </td> </tr> </table> <table width="95%" height="207" border="0" align="center" cellpadding="0" cellspacing="4"> <tr> <td height="199"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/95120.html" title="Come visualizzare i nomi dei file in una Listbox " target="_self">Come visualizzare i nomi dei file in una Listbox </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/cc-programming/85724.html" title="Come usare array di caratteri bidimensionali in C " target="_self">Come usare array di caratteri bidimensionali in C </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/87101.html" title="Come fare un gioco Pig in pseudocodice " target="_self">Come fare un gioco Pig in pseudocodice </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/cc-programming/85993.html" title="Visual C 2005 Tutorial " target="_self">Visual C 2005 Tutorial </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/95314.html" title="Come aggiungere una password in Visual Basic 6 " target="_self">Come aggiungere una password in Visual Basic 6 </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/88706.html" title="Come creare una modulazione di larghezza di impulso ( PWM) in un modulo Verilog per l'esecuzione di un Motor /Servo " target="_self">Come creare una modulazione di larghezza di impulso ( P…</a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/java-programming/90651.html" title="Come progettare giochi in Java " target="_self">Come progettare giochi in Java </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/visual-basics-programming/96300.html" title="Come stampare in un Didascalia etichette in Visual Basic 6.0 " target="_self">Come stampare in un Didascalia etichette in Visual Basi…</a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/cc-programming/85541.html" title="Come compilare C Progetti " target="_self">Come compilare C Progetti </a></td></tr><tr><td width="10" valign="top" class="">·</td><td class=""><a class="" href="/Programmazione/computer-programming-languages/87293.html" title="Come esportare VBA per una cartella " target="_self">Come esportare VBA per una cartella </a></td></tr><tr></tr></table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table> <table width="980" height="8" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <table border=0 cellSpacing=0 cellPadding=0 width=980 bgColor=#36506e height=90> <tr> <td class=bs height=90 align=middle>Copyright © Conoscenza Informatica http://it.wingwit.com <script language='javascript' src='/ad/201310/1.js'></script></td> </tr> </table> </div> </body> </html>