<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[mi stampa piu volte la checkbox]]></title><description><![CDATA[<p dir="auto">ciao ragazzi, in questa pagina col while stampo i nomi di tutte le categorie del db, mentre col for mi prende quelle che l'utente ha precedentemente selezionato. quindi se la categoria è stata in precedenza scelta la checkbox sarà spuntata altrimenti no.<br />
il problema è che funziona bene nel senso che le categorie scelte vengono spuntate, ma il poblema è che mi stampa piu volte le checkbox.</p>
<pre><code>&lt;?php
//Includo i file per la connessione
//e per la verifica Utente
require_once('connessione.php');
require_once('verificalogin.php');
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;CREA IL TUO PROFILO &lt;/h1&gt;
&lt;form action="creaprofilo.php" method="post" &gt;
&lt;?php

if(isset($_SESSION['utente'])){
    
$user=$_SESSION['utente'][0];
//echo $user;
}
else{
echo "errore utente";
}

     
     $query1 = "SELECT * FROM utente WHERE username = '$user'"; 
     $result1 = mysql_query($query1) or die("Errore nella query1:".mysql_error()); 
     $row = mysql_fetch_assoc($result1); 
     $idutente = $row['idutente'];
     

    $query="select * from seleziona where idutente='$idutente'";
    $result1 = mysql_query($query) or die("Errore nella query1:".mysql_error()); 
    $numerorighe = mysql_num_rows($result1); 

for($x=0; $x&lt;$numerorighe; $x++){ //mi estrago dal db solo le categorie scelte

$riga = mysql_fetch_array($result1); 
$idcategoria1 = $riga['idcategoria'];
//echo $idcategoria1;
                                



$query="select * from categoria where idpadre='0' order by idcategoria";
$result = mysql_query($query);
while($fetch=mysql_fetch_array($result)) { //mi estraggo dal db
    $query="select * from categoria where idpadre='".$fetch['idcategoria']."' order by idcategoria";
    $risultato=mysql_query($query);
    
    
    echo "&lt;b&gt;".$fetch['nome']."&lt;/b&gt;&lt;br&gt;";
    
    while($array=mysql_fetch_array($risultato)) {
    
        $idcat= $array['idcategoria'];
        echo $array['nome'];
        
        if ($idcategoria1==$idcat){
    echo '&lt;input type=checkbox checked name="'.$array['nome'].'" value="'.$array['idcategoria'].'" /&gt;&lt;br /&gt;';
    echo "&lt;br&gt;";
        }
        else 
        {
    echo '&lt;input type="checkbox" name="'.$array['nome'].'" value="'.$array['idcategoria'].'" /&gt;&lt;br /&gt;';
         echo "&lt;br&gt;";
         }
        
    
}

} }




 ?&gt;
&lt;input name="" type="submit"&gt;
&lt;/form&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/topic/22829/mi-stampa-piu-volte-la-checkbox</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 11:26:29 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/22829.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 Dec 2006 16:17:36 GMT</pubDate><ttl>60</ttl></channel></rss>