Newsgroup: it.comp.www.php
Titolo: PHP MYSQL

Ciao a tutti,
mi potete aiutare ad eseguire una query con php?
 
Ho creato una pagina con un form:
http://i1252.photobucket.com/albums/hh577/photobucketdavidemi/search.jpg
 
 
Vorrei che mi restituisse tutti i valori inseriti facendomeli 
visualizzare in questa pagina:
 
http://i1252.photobucket.com/albums/hh577/photobucketdavidemi/risultato.jpg
 
 
Grazie


dovresti essere un po' più dettagliato.
Che campi ha la tebella/e del database?
In che rapporto sono i dati che comparirebbero nelle pagine delle quali 
hai dato il link?
Che tipo di query ti interessa?
Leonardo
 


Praticamente vorrei che mi restituisse per i vari numeri interni il 
corrispettivo nome e cognome, invece mi restituisce solo info del primo 
campo di testo.
 
 > Che tipo di query ti interessa?
 
Ricerca di più numeri all'interno del DB(mysql)
 
 > Leonardo
 >
 
 
http://i1252.photobucket.com/albums/hh577/photobucketdavidemi/search.jpg
 
eccolo il codice :
 
<!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=utf-8" />
<title>Documento senza titolo</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #FFFFFF;
	font-weight: bold;
}
body {
	background-color: #FF9933;
}
h1,h2,h3,h4,h5,h6 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.Stile1 {color: #000000}
.cssform {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-style: normal;
	font-weight: bold;
	color: #000000;
	background-color: #FFFFFF;
	border-top-width: thin;
	border-right-width: thin;
	border-bottom-width: thin;
	border-left-width: thin;
	border-top-color: #FFFFFF;
	border-right-color: #FFFFFF;
	border-bottom-color: #FFFFFF;
	border-left-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
   if (document.getElementById){
     var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
     for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; 
val=document.getElementById(args[i]);
       if (val) { nm=
val.name
; if ((val=val.value)!="") {
         if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
           if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain 
an e-mail address.\n';
         } else if (test!='R') { num = parseFloat(val);
           if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
           if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
             min=test.substring(8,p); max=test.substring(p+1);
             if (num<min || max<num) errors+='- '+nm+' must contain a 
number between '+min+' and '+max+'.\n';
       } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is 
required.\n'; }
     } if (errors) alert('The following error(s) occurred:\n'+errors);
     document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>
 
<body>
<form action="risultato2.php" method="post" name="form" id="form">
   <label></label>
   <div align="center" class="Stile1"></div>
   <table width="200" border="0" align="center">
     <tr>
       <td width="108"><div align="center">Inserisci Numero</div></td>
       <td width="82"><div align="center">
         <input name="number1" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number1','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number2" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number1','','NisNum','number2','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number3" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number1','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number4" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number4','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number5" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number5','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number6" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number6','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number7" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number7','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number8" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number8','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number9" type="text" class="cssform" id="number" 
onblur="MM_validateForm('number9','','NisNum');return 
document.MM_returnValue" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number10" type="text" class="cssform" id="number" 
size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number11" type="text" class="cssform" id="number" 
size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number12" type="text" class="cssform" id="number" 
size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number13" type="text" class="cssform" id="number" 
size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number14" type="text" class="cssform" id="number" 
size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number15" type="text" class="cssform" id="number" 
size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number16" type="text" class="cssform" 
id="number16" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number17" type="text" class="cssform" id="number" 
size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number18" type="text" class="cssform" 
id="number18" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number19" type="text" class="cssform" 
id="number19" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number20" type="text" class="cssform" 
id="number20" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number21" type="text" class="cssform" 
id="number21" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number22" type="text" class="cssform" 
id="number22" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number23" type="text" class="cssform" 
id="number23" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number24" type="text" class="cssform" 
id="number24" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number25" type="text" class="cssform" 
id="number25" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number26" type="text" class="cssform" 
id="number26" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number27" type="text" class="cssform" 
id="number27" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number28" type="text" class="cssform" 
id="number28" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">Inserisci Numero</div></td>
       <td><div align="center">
         <input name="number29" type="text" class="cssform" 
id="number29" size="4" maxlength="4" />
       </div></td>
     </tr>
     <tr>
       <td><div align="center">
         <input name="Reset" type="reset" class="cssform" id="Reset" 
value="Reset" />
       </div></td>
       <td><div align="center">
         <input name="invia" type="submit" class="cssform" id="invia" 
value="Invia" />
       </div></td>
     </tr>
   </table>
</form>
<p>&nbsp;</p>
</body>
</html>
 
http://i1252.photobucket.com/albums/hh577/photobucketdavidemi/risultato.jpg
 
ecco il codice
<?php require_once('Connections/conn_db.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;
}
}
 
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
   $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
 
$colname_Recordset1 = "-1";
if (isset($_POST['number1'])) {
   $colname_Recordset1 = $_POST['number1'];
}
mysql_select_db($database_conn_db, $conn_db);
$query_Recordset1 = sprintf("SELECT * FROM sheet1 WHERE INTERNO = %s", 
GetSQLValueString($colname_Recordset1, "text"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, 
$startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conn_db) or 
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
 
if (isset($_GET['totalRows_Recordset1'])) {
   $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
   $all_Recordset1 = mysql_query($query_Recordset1);
   $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!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=utf-8" />
<title>Documento senza titolo</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #663300;
	font-weight: bold;
}
body {
	background-color: #FF9900;
}
h1,h2,h3,h4,h5,h6 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
-->
</style></head>
 
<body>
<p>&nbsp;</p>
 
<table border="1" align="center" bordercolor="#000000">
   <tr>
     <td><div align="center">ID</div></td>
     <td><div align="center">SEDE</div></td>
     <td><div align="center">COGNOME</div></td>
     <td><div align="center">NOME</div></td>
     <td><div align="center">INTERNO</div></td>
     <td><div align="center">CRIS</div></td>
     <td><div align="center">CPL</div></td>
     <td><div align="center">POS</div></td>
     <td><div align="center">1A-COPPIA</div></td>
     <td><div align="center">NUMERO PRESA</div></td>
   </tr>
   <?php do { ?>
     <tr>
       <td><div align="center"><?php echo $row_Recordset1['ID']; 
?></div></td>
       <td><div align="center"><?php echo $row_Recordset1['SEDE']; 
?></div></td>
       <td><div align="center"><?php echo $row_Recordset1['COGNOME']; 
?></div></td>
       <td><div align="center"><?php echo $row_Recordset1['NOME']; 
?></div></td>
       <td><div align="center"><?php echo $row_Recordset1['INTERNO']; 
?></div></td>
       <td><div align="center"><?php echo $row_Recordset1['CRIS']; 
?></div></td>
       <td><div align="center"><?php echo $row_Recordset1['CPL']; 
?></div></td>
       <td><div align="center"><?php echo $row_Recordset1['POS']; 
?></div></td>
       <td><?php echo $row_Recordset1['1A-COPPIA']; ?></td>
       <td><?php echo $row_Recordset1['NUMERO PRESA']; ?></td>
     </tr>
     <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
 
 
 

 campo di testo.
 
Ho provato a leggere il tuo codice, ma l'unico consiglio che posso darti 
e`: smetti di copiaincollare codice in giro, e impara a programmare (PHP, 
HTML e SQL) partendo dalle basi.
 
Bye.
 

 >> Grazie
 
Errore 1:
Nella prima pagina, quella del form, non usi id diversi per ogni modulo
 
Errore 2:
Nella seconda non usi un ciclo foreach per estrarre tutti i vari $_POST
e poi passarli alla query
 
Errore 3:
Usare Dreamweaver per queste cose non va bene perchè non ha nel suo DNA
il poter costruire script di questo tipo (vedi per es. la paginazione,
che DW con i suoi behaviours non gestisce proprio in modo "bello"), devi
metterci mano tu con del codice scritto ad-hoc
 
Consiglio:
Ti sei chiesto come funziona la tua query di ricerca? Prova ad
analizzare come dovrebbe funzionare il flusso dello script.
 
Dalla prima pagina compili tutti i campi (perchè poi obbligatoriamente
tutti?) e passi un array di numeri alla seconda pagina, dove usi questo
array per interrogare il Db ed estrarre i dati.
Ma senza un ciclo foreach(), tu interroghi il db solo con l'ultimo id
dell'array!
 
Max
 
-- 
http://www.maxori.it
 
L'Arte è la capacità di fare cose di nessun valore
e di riuscire a venderle
F. Zappa