Ok
selezionaStagione è la funzione che dovrebbe essere attivata selezionando il menù a tendina
id nel db è un numero
Codice PHP:
<?php
print("<form method='post' action='mod2.php'>");
print("<select name='stagioni' id='stagioni' onchange='stagioneSelezionata(stagioni.value)'>");
print("<option id='0' value=''></option>");
function connect()
{
$dbUser = "francesco";
$dbPass = "francesco";
$dbName = "calcetto";
$dbHost = "localhost";
if (!($link=mysql_connect('localhost', $dbUser, $dbPass))) {
print("Errore nella connessione al database");
}
if (!mysql_select_db($dbName, $link)) {
print("Errore nella selezione del database ".$dbName);
}
return $link;
}
function stagioneSelezionata($id)
{
if($id != "") // se id è "" non scrivo nulla
{
$link = connect();
$result = mysql_query("select commento from stagione where id='".$id."'");
$commentoSelezionato = mysql_fetch_row($result);
// IN TEORIA DA QUI DOVREI CONTROLLARE LA TEXTAREA commento
mysql_close($link);
}
}
$link = connect();
$result = mysql_query("select id, anno from stagione");
while( $stagione_corrente=mysql_fetch_row($result) )
{
print("<option id=".$stagione_corrente[0]." value=".$stagione_corrente[0].">".$stagione_corrente[1]."</option>");
}
mysql_close($link);
?>
</select>
<textarea id="commento" cols="40" rows="4">
</textarea>
<input type="submit" value="Ok">
</form>
E' da poco che mi affaccio a PHP speriamo di non aver scritto strafalcioni