Se avete un muro + grosso di questodatemelo pure
ho un database esempio composto da 5 campi id-numero_tessera_socio-cognome-nome-corso.
ho creato una pagina inserimento tramite session che le passo ad un'altra pagina x controllare se i dati inseriti vanno bene se si vado ad inserirli.
In quest'ultima pagina ho aggiunto delle array e un contatore dove se il valore compreso nel campo corso è = 3 mi deve dire corso completo ma non ne vuole sapere dove sbaglio?
codice prima pagina inserimento
Codice seconda pagina controllo e dove dovrebbe fare il conteggio arraycodice:<?php session_start(); $_SESSION['numero_tessera_socio'] = $_POST['numero_tessera_socio']; $_SESSION['cognome'] = $_POST['cognome']; $_SESSION['nome'] = $_POST['nome']; $_SESSION['corso'] = $_POST['corso']; ?> <!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>Documento senza titolo</title> </head> <body> </p> <form id="form1" name="form1" method="post" action="prova2.php"> <table width="814" border="1"> <tr> <td width="75">id</td> <td width="317"><label> <input name="id" type="text" id="id" /> </label></td> <td width="196">numero tessera </td> <td width="198"><label> <input name="numero_tessera_socio" type="text" id="numero_tessera_socio" value= "<?php $_SESSION['numero_tessera_socio']?>" /> </label></td> </tr> <tr> <td>cognome</td> <td><label> <input name="cognome" type="text" id="cognome" value= "<?php $_SESSION['cognome']?>"/> </label></td> <td>nome</td> <td><label> <input name="nome" type="text" id="nome" value= "<?php $_SESSION['nome']?>" /> </label></td> </tr> <tr> <td>corso</td> <td><label> <select name="corso" id="corso" value= "<?php $_SESSION['corso']?>"> <OPTION selected>[b] -SELEZIONA ORARIO-[b]</OPTION> <OPTION value=Lunedi1115>Lunedì-Mercoledì 11:15-12:00</OPTION> <OPTION value=Lunedi1315>Lunedì-Mercoledì 13:15-14:00</OPTION> <OPTION value=Martedi2045>Martedì-Giovedì 20:45-21:30</OPTION> <OPTION value=Lunedi2130>Martedì-Giovedì 21:30-22:15</OPTION> </select> </label></td> <td></td> <td></td> </tr> </table> <label> <input type="submit" name="Submit" value="Invia" /> </label> </p> </form> </p> </body> </html>
codice:<?php require_once('Connections/palestra.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO esempio (id, numero_tessera_socio, cognome, nome, corso) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['numero_tessera_socio'], "text"), GetSQLValueString($_POST['cognome'], "text"), GetSQLValueString($_POST['nome'], "text"), GetSQLValueString($_POST['corso'], "text")); mysql_select_db($database_palestra, $palestra); $Result1 = mysql_query($insertSQL, $palestra) or die(mysql_error()); $insertGoTo = "prova1.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_palestra, $palestra); $query_Recordset1 = "SELECT * FROM esempio"; $Recordset1 = mysql_query($query_Recordset1, $palestra) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); session_start(); ?> <!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>Documento senza titolo</title> </head> <body> <?php $corso[0] = “Lunedi1115”; $corso[1] = “Lunedi1315”; $corso[2] = “Martedi2045”; $corso[3] = “Martedi2130”; for ( $i=1 ; $i<= count($corso) ; $i++ ){ if($corso[0] >= 2) print "<td>corso completo</td>"; else print "<td>Fine prova</td>"; } ?> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <table width="814" border="1"> <tr> <td width="75">id</td> <td width="317"><label> <input name="id" type="text" id="id" value= "<?php echo $id;?>"/> </label></td> <td width="196">numero tessera </td> <td width="198"><label> <input name="numero_tessera_socio" type="text" id="numero_tessera_socio" value= "<?php echo $numero_tessera_socio;?>" /> </label></td> </tr> <tr> <td>cognome</td> <td><label> <input name="cognome" type="text" id="cognome" value= "<?php echo $cognome;?>"/> </label></td> <td>nome</td> <td><label> <input name="nome" type="text" id="nome" value= "<?php echo $nome;?>" /> </label></td> </tr> <tr> <td>corso</td> <td><label> <input name="corso" type="text" id="corso" value= "<?php echo $corso;?>"/> </label></td> <td></td> <td></td> </tr> </table> <label> <input type="submit" name="Submit" value="Invia" /> </label> indietro</p> <input type="hidden" name="MM_insert" value="form1"> </form> </p> </body> </html> <?php mysql_free_result($Recordset1); ?>>

datemelo pure
Rispondi quotando
