Se scrivi:
Codice PHP:
<?php
require "db_conn.php";
$query = "SELECT * FROM sondaggio";
$result = mysql_query($query, $db_connect) or die("Errore...");
$array = mysql_fetch_array($result);
$domanda= $array[1];
$numrows = mysql_num_rows($result);
ti sei "mangiato" la prima riga!!!
infatti $array[0] contiene l'id della prima riga, $array[2] l'opzione e $array[3] i voti
quindi, considerando questo, il codice potrà essere:
Codice PHP:
<?php
require "db_conn.php";
$query = "SELECT * FROM sondaggio";
$result = mysql_query($query, $db_connect) or die("Errore...");
$array = mysql_fetch_array($result);
$domanda= $array[1];
$numrows = mysql_num_rows($result);
print "<table height=237 bgcolor=#993333>
<tr>
<th rowspan=\"2\" width=\"1\"></th>
<th width=\"138\" height=\"23\"><span class=\"Stile1\">Sondaggio </span></th>
<th rowspan=\"2\" width=\"1\"></th>
</tr>
<th height=\"185\"> <table bgcolor=\"#000000\" width=\"138\" height=\"198\">
<tr>
<th height=\"37\" colspan=\"2\"><span class=\"Stile1\">$domanda</span></th>
</tr>
<form action=\"scriptso.php\" method=\"post\" name=\"sondaggio\" id=\"sondaggio\">";
// Scrivo i dati della prima riga, che ho già 'in canna'
$id = $array[0];
$opzione = $array[2];
$voti = $array[3];
print "<tr>
<th width=\"34\"><input name=voto type=radio id=$id value=$opzione /></th>
<th height=\"26\"><span class=Stile1>$opzione</span></th>
</tr>";
{
for($x=1; $x<$numrows; $x++){ //ATTENZIONE! da 1 non da 0
$resrow = mysql_fetch_row($result);
$id = $resrow[0];
$opzione = $resrow[2];
$voti = $resrow[3];
print "<tr>
<th width=\"34\"><input name=voto type=radio id=$id value=$opzione /></th>
<th height=\"26\"><span class=Stile1>$opzione</span></th>
</tr>";
}
};
print "<tr>
<th height=\"27\"><span class=\"Stile1\"></span></th>
<th width=\"92\"><input name=\"submit\" type=\"image\" src=\"grafica/button.gif\" alt=\"vota\" /></th>
</tr>
</form>
</table>
</th>
</tr>
<tr width=\"4\">
<th height=\"4\" colspan=\"3\" ></th>
</tr>
</table>";
?>
HTH
Zappa