Salve,
Sto cercando di creare una pagina in php che permetta di calcolare i punti lotta che avrà il pokemon che si vuole.
Ho creato una pagina html con un codice php che moltiplica un inbox vuota dove l'utente inserisce l'attuale livello del pokemon e poi un selecet dove l'utente sceglie il pokemon che ha e poi calcola il livello.
Ogni pokemon ha un valore solo che alcuni pokemon possono avere più valori e non so come rendere possibile la cosa.
Vi lascio la sorgente del codice qui sotto.
[PHP]<!doctype html><html><head><meta charset="UTF-8"><title>prova calcolatrice</title></head><body><?php
//Recupero i dati del form
$num1 = $_POST['num1']; $num2 = $_POST['num2'];
//Verifico che i dati immessi siano numeri
if (!$num1 || !$num2 || !is_numeric($num1) || !is_numeric($num2) )
{
print "Errore";
}else{
print "<b>$num1</b> x <b>$num2</b> </b> = PL " .($num1 * $num2 ); }
?> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"><table><tr><td><input name="num1" type="text" id="num1" value=""/></td><td>X</td>
<select name="num2" id="num2"><option name="num2" id="num2" value="">Select a Pokemon</option><option name="num2" id="num2" value="1.95">Abra</option><option name="num2" id="num2" value="1.57">Bellsprout</option><option name="num2" id="num2" value="1.58">Bulbasaur</option><option name="num2" id="num2" value="1.58">Bulbasaur</option><option name="num2" id="num2" value="1.05">Caterpie</option><option name="num2" id="num2" value="1.65">Charmander</option><option name="num2" id="num2" value="1.79">Charmeleon</option><option name="num2" id="num2" value="2.03">Clefairy</option><option name="num2" id="num2" value="1.67">Cubone</option><option name="num2" id="num2" value="2.68">Diglett</option><option name="num2" id="num2" value="2.19">Doduo</option><option name="num2" id="num2" value="2.05">Dragonair</option><option name="num2" id="num2" value="1.8">Dratini</option><option name="num2" id="num2" value="2.08">Drowzee</option><option name="num2" id="num2" value="2.02">Eevee</option><option name="num2" id="num2" value="2.21">Ekans</option><option name="num2" id="num2" value="2.70">Exeggcute</option><option name="num2" id="num2" value="1.78">Gastly</option><option name="num2" id="num2" value="1.75">Geodude</option><option name="num2" id="num2" value="1.49">Gloom</option><option name="num2" id="num2" value="2.15">Goldeen</option><option name="num2" id="num2" value="1.64">Graveler</option><option name="num2" id="num2" value="2.44">Grimer</option><option name="num2" id="num2" value="2.31">Growlithe</option><option name="num2" id="num2" value="1.56">Haunter</option><option name="num2" id="num2" value="2.23">Horsea</option><option name="num2" id="num2" value="1.2">Ivysaur</option><option name="num2" id="num2" value="1.85">Jigglypuff</option><option name="num2" id="num2" value="1.97">Kabuto</option><option name="num2" id="num2" value="1.4">Kadabra</option><option name="num2" id="num2" value="3.01">Kakuna</option><option name="num2" id="num2" value="2.36">Krabby</option><option name="num2" id="num2" value="1.7">Machoke</option><option name="num2" id="num2" value="1.64">Machop</option><option name="num2" id="num2" value="10.1">Magikarp</option><option name="num2" id="num2" value="2.16">Magnemite</option><option name="num2" id="num2" value="2.17">Mankey</option><option name="num2" id="num2" value="1.98">Meowth</option><option name="num2" id="num2" value="3.55">Metapod</option><option name="num2" id="num2" value="1.64">Nidoran(Female)</option><option name="num2" id="num2" value="1.72">Nidoran(Male)</option><option name="num2" id="num2" value="1.83">Nidorina</option><option name="num2" id="num2" value="1.03">Nidorino</option><option name="num2" id="num2" value="1.5">Oddish</option><option name="num2" id="num2" value="2.12">Omanyte</option><option name="num2" id="num2" value="2.02">Paras</option><option name="num2" id="num2" value="1.79">Pidgeotto</option><option name="num2" id="num2" value="1.71">Pidgey</option><option name="num2" id="num2" value="2.34">Pikachu</option><option name="num2" id="num2" value="1.72">Poliwag</option><option name="num2" id="num2" value="1.95">Poliwhirl</option><option name="num2" id="num2" value="1.48">Ponyta</option><option name="num2" id="num2" value="2.27">Psyduck</option><option name="num2" id="num2" value="2.55">Rattata</option><option name="num2" id="num2" value="1.92">Rhyhorn</option><option name="num2" id="num2" value="2.45">Sandshrew</option><option name="num2" id="num2" value="1.04">Seel</option><option name="num2" id="num2" value="2.65">Shellder</option><option name="num2" id="num2" value="2.21">Slowpoke</option><option name="num2" id="num2" value="2.66">Spearow</option><option name="num2" id="num2" value="2.1">Squirtle</option><option name="num2" id="num2" value="2.38">Staryu</option><option name="num2" id="num2" value="2.52">Tentacool</option><option name="num2" id="num2" value="1.86">Venonat</option><option name="num2" id="num2" value="2.01">Voltorb</option><option name="num2" id="num2" value="2.74">Vulpix</option><option name="num2" id="num2" value="2.74">Wartortle</option><option name="num2" id="num2" value="1.01">Weedle</option><option name="num2" id="num2" value="1.59">Weepinbell</option><option name="num2" id="num2" value="2.6">Zubat</option>
</tr></select></tr><tr><td colspan="3"><input type="submit" value="Calcola"/></td>
</tr></table></form>
</body></html>[/PHP]