Ti posto tutto il codice è da poco che mi sono avvicinato al php e non sono molto esperto.
Codice PHP:
<?php
function list_data(){
$id= array();
$seq = array();
$cognome = array();
$comuni = array();
$db = mysql_connect("localhost","root","");
mysql_select_db("Generale", $db);
$result =mysql_query("SELECT * FROM studenti Where ID=$ID" );
while($myrow=mysql_fetch_array($result))
$query =mysql_query("SELECT foglio1.Id, foglio1.Seq , studenti.cognome, studenti.Id, .studenti.Comune FROM studenti, foglio1 Where foglio1.Id=studenti.Id and Seq='$myrow[Seq]'");
while($myrow=mysql_fetch_array($query)){
$id[] = $myrow['Id'];
$seq[] = $myrow['Seq'];
$cognome[] = $myrow['Cognome'];
$comuni[] = $myrow['Comune'];
}
return array("Id" => $id, "Seq" => $seq, "Cognome" => $cognome, "Comune" => $comuni);
}
function print_data($array){
$html = "";
for($i=0;$i<=count($array['id']);$i++){
$html .= "<tr>
<td align= 'center'>{$array['id'][$i]}</td>
<td align= 'center'>{$array['seq'][$i]}</td>
<td align= 'center'>{$array['cognome'][$i]}</td>
<td align= 'center'>{$array['comune'][$i]}</td>
</tr>";
}
return $html;
}
//utilizzo
$data = list_data();
echo print_data($data);
?>