Con questo codice con la query action1 riesco ad aggiornare soltanto il primo dei record estratti dalla prima query... qualcuno può aiutarmi?
Codice PHP:
<?PHP
include("db.php");
$tipo=$_REQUEST["tipo"];
if ($_REQUEST["t"] == 'p'):
$t = "PASSIVI";
$las = 5;
elseif ($_REQUEST["t"] == 'a'):
$t = "ATTIVI";
$las = 0;
endif;
if ($_REQUEST["tipo"] == 'pro'):
$titolo = "PROFESSIONISTI";
elseif ($_REQUEST["tipo"] == 'pub'):
$titolo = "PUBBLICISTI";
else:
print "<h1>ERRORE CODICE LISTA </h1>
";
endif;
//ELENCO IN ORDINE ALFABETICO - tipo = pub, pro
$query_elenco = "SELECT id_ass,cognome_nome,cod_fiscale,pro_dataiscr,pub_dataiscr,spe_dataiscr,pra_dataiscr,
num_tessera, indirizzo_res, concat(cap_res,'-',comune_res,'-','(',prov_res,')') as
indirizzoresidenza, indirizzo_dom, concat(cap_dom,'-',comune_dom,'-','(',prov_dom,')') as
indirizzodomicilio, selezione_ind, selezione_ind2 FROM anagrafica WHERE (prov_res
LIKE '".$_REQUEST["pr"]."') AND (".$_REQUEST["tipo"]."_att !=0) AND sospeso=0 AND
cancellato=0 AND deceduto=0 ORDER BY cognome_nome";
$risultato = mysql_query($query_elenco, $connessione);
$num_righe = mysql_query($risultato);
while ($row = mysql_fetch_array($risultato))
{
$oggi = getdate();
$anno = $oggi['year'];
if (!function_exists('elettorato')) {
function elettorato($temp)
{
if($temp == '0000-00-00')
return FALSE;
$temp = explode("-",$temp);
$oggi = explode("-",date("Y-m-d"));
if ($oggi[1] > $temp[1])
return $oggi[0] - $temp[0];
elseif ($oggi[1] >= $temp[1] && $oggi[2] >= $temp[2])
return $oggi[0] - $temp[0];
else
return $oggi[0] - $temp[0] - 1;
}
}
$lasso = elettorato($row['pro_dataiscr']);
$lasso1 = elettorato($row['pub_dataiscr']);
}
$action1 = "UPDATE anagrafica SET las1 = '$lasso' WHERE id_ass = $row[id_ass]";
$query1 = mysql_query ($action1);
?>