<?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[Checkbox]]></title><description><![CDATA[<p dir="auto">Ciao a tutti<br />
ho un problemino risolto solo a metà, vi spiego<br />
nella tabella pippo ho un campo chiamato optional classificata come text , all'interno ci sono delle stringhe quali<br />
testo1, testo2, testo3,testo4,testo5<br />
devo verificare se questi campi sono presenti in un array ed estrapolarli facendoli apparire in checkbox ceccati<br />
vi posto lo script</p>
<pre><code class="language-php">$query_estr=mysql_query("SELECT * From pippo")
or die("errore nella query;".mysql_error());
$ultimo=mysql_fetch_object($query_estr);
$a_optional=array('testo1', 'testo2', 'testo3', 'testo4', 'testo5', 'testo6', 'testo7');
for($i=0; $i&lt;count($a_optional); $i++)
 {
   if($ultimo-&gt;optional = "$a_optional[$i]")
   {
    print"
     &lt;input type='checkbox' name='optional$i' value='optional$i' checked='checked'/&gt;$a_optional[$i]";
   }
  else
   {
    print"Ciao";
   }
 }
</code></pre>
<p dir="auto">Il problema è che me li estrae tutti e li metti nelle checkbox<br />
ma questa istruzione è giusta?</p>
<pre><code class="language-php">if($ultimo-&gt;optional = "$a_optional[$i]")
</code></pre>
<p dir="auto">Grazie in anticipo da danny</p>
]]></description><link>https://dev.connect.gt/topic/143199/checkbox</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 08:54:21 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/143199.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Jan 2011 22:59:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Checkbox on Fri, 21 Jan 2011 15:22:35 GMT]]></title><description><![CDATA[<p dir="auto">Ciao a tutti, ultima cosa fatta, ma da errore alla riga dove faccio il confronto</p>
<pre><code class="language-php">$query_estr=mysql_query("SELECT * From pippo")
or die("errore nella query;".mysql_error());
$ultimo=mysql_fetch_object($query_estr);
//print $ultimo-&gt;optional;  qua dentro ho testo1,testo2,testo3
$oper=explode(',',$ultimo-&gt;optional);
for($i=0; $i&lt;count($oper); $i++)
{
 print $oper[$i]; //qua dentro c'è testo1testo2testo3
}
$a_optional=array('testo1', 'testo2', 'testo3', 'testo4', 'testo5', 'testo6', 'testo7', 'testo8');
$check="";
$riga=1;
print"
&lt;table cellpadding='0' cellspacing='0' border='0' bordercolor='#23D527'&gt;";
for($f=0; $f&lt;count($a_optional); $f++)
 {
  if($oper[$i]==$a_optional[$f])
   {
    $check="checked";
   }
  else
   {
    $check="";
   }
  if($riga == 1)
   {
    print"&lt;tr&gt;"; 
   }
    print"
     &lt;td width='200' class='testo'&gt;
      &lt;input type='checkbox' name='$f' $check&gt;$a_optional[$f]
     &lt;/td&gt;";
     $riga++;
  if($riga &gt; 2)
   {
    print"&lt;/tr&gt;";
    $riga=1; 
   }
 }
print"
&lt;/table&gt;";
</code></pre>
]]></description><link>https://dev.connect.gt/post/965758</link><guid isPermaLink="true">https://dev.connect.gt/post/965758</guid><dc:creator><![CDATA[danny1975]]></dc:creator><pubDate>Fri, 21 Jan 2011 15:22:35 GMT</pubDate></item><item><title><![CDATA[Reply to Checkbox on Fri, 21 Jan 2011 14:27:15 GMT]]></title><description><![CDATA[<p dir="auto">Ciao a tutti per adesso sono arrivato a fare l'explode</p>
<pre><code class="language-php">$query_estr=mysql_query("SELECT * From pippo")
or die("errore nella query;".mysql_error());
$ultimo=mysql_fetch_object($query_estr);
//print $ultimo-&gt;optional; qua dentro c'è testo1,testo2,testo3
$oper=explode(',',$ultimo-&gt;optional);
$a_optional=array('testo1', 'testo2', 'testo3', 'testo4', 'testo5', 'testo6', 'testo7', 'testo8');
$riga=1;
print"
&lt;table cellpadding='0' cellspacing='0' border='0' bordercolor='#23D527'&gt;";
for($f=0; $f&lt;count($a_optional); $f++)
 {
  if($riga == 1)
   {
    print"&lt;tr&gt;"; 
   }
    print"
     &lt;td width='200' class='testo'&gt;
      &lt;input type='checkbox' name='$f'&gt;$a_optional[$f]
     &lt;/td&gt;";
     $riga++;
  if($riga &gt; 2)
   {
    print"&lt;/tr&gt;";
    $riga=1; 
   }
 }
print"
&lt;/table&gt;";
</code></pre>
<p dir="auto">Il problema è sempre lo stesso adesso dovrei far visualizzare le 10 check di cui 3 devono essere checcate</p>
]]></description><link>https://dev.connect.gt/post/965756</link><guid isPermaLink="true">https://dev.connect.gt/post/965756</guid><dc:creator><![CDATA[danny1975]]></dc:creator><pubDate>Fri, 21 Jan 2011 14:27:15 GMT</pubDate></item><item><title><![CDATA[Reply to Checkbox on Wed, 19 Jan 2011 18:39:59 GMT]]></title><description><![CDATA[<p dir="auto">Ciao ragazzi non dimenticatevi di me<br />
intanto sto ancora facendo prove, risultato zero<br />
Ciao da danny</p>
]]></description><link>https://dev.connect.gt/post/965753</link><guid isPermaLink="true">https://dev.connect.gt/post/965753</guid><dc:creator><![CDATA[danny1975]]></dc:creator><pubDate>Wed, 19 Jan 2011 18:39:59 GMT</pubDate></item><item><title><![CDATA[Reply to Checkbox on Sun, 16 Jan 2011 21:50:57 GMT]]></title><description><![CDATA[<p dir="auto">Ciao ragazzi, vi sarei grato se mi deste un aiuto</p>
<p dir="auto">Grazie da danny</p>
]]></description><link>https://dev.connect.gt/post/965751</link><guid isPermaLink="true">https://dev.connect.gt/post/965751</guid><dc:creator><![CDATA[danny1975]]></dc:creator><pubDate>Sun, 16 Jan 2011 21:50:57 GMT</pubDate></item><item><title><![CDATA[Reply to Checkbox on Sat, 15 Jan 2011 17:01:21 GMT]]></title><description><![CDATA[<p dir="auto">Ciao a tutti qua è un macello, prove su prove, ma non riesco a far comparire quello che voglio.<br />
Mi vorrei rispiegare<br />
Il punto non è estrapolare dei dati separati da una virgola, quello facendo explode va bene, il problema è; dato un array composto da 10 elementi, quando faccio la insert è stato scelto di inserirne 3, qualcosa non è andato a buon fine, e devo ritornare alla pagina precedente contenente le 10 checkbox, ma di queste dieci 3 dovranno essere ceccate e 7 dovranno essere vuote, come faccio a fare una cosa del genere, forse non sara difficile, ma visto che sto da stamattina mi sto esaurendo</p>
<pre><code class="language-php">//Nella cella optional della tabella pippo ho testo1,testo2,testo3
$query_estr=mysql_query("SELECT * From pippo")
or die("errore nella query;".mysql_error());
$ultimo=mysql_fetch_object($query_estr);
$a_optional=array('testo1', 'testo2', 'testo3', 'testo4', 'testo5', 'testo6', 'testo7', 'testo8', 'testo9', 'testo10');
$riga=1;
print"
&lt;table cellpadding='0' cellspacing='0' border='0'&gt;";
for($f=0; $f&lt;count($a_optional); $f++)
 {
  if($riga == 1)
   {
    print"&lt;tr&gt;"; 
   }
    print"
     &lt;td width='200' class='testo'&gt;
      &lt;input type='checkbox' name='$f'&gt;$a_optional[$f]
     &lt;/td&gt;";
     $riga++;
  if($riga &gt; 2)
   {
    print"&lt;/tr&gt;";
    $riga=1; 
   }
 }
print"
&lt;/table&gt;";
</code></pre>
<p dir="auto">Ciao da danny</p>
]]></description><link>https://dev.connect.gt/post/965750</link><guid isPermaLink="true">https://dev.connect.gt/post/965750</guid><dc:creator><![CDATA[danny1975]]></dc:creator><pubDate>Sat, 15 Jan 2011 17:01:21 GMT</pubDate></item><item><title><![CDATA[Reply to Checkbox on Sat, 15 Jan 2011 11:53:50 GMT]]></title><description><![CDATA[<pre><code class="language-php">print"
&lt;table cellpadding='0' cellspacing='0' border='0' bordercolor='#23D527'&gt;";
$riga=1;
for($f=0; $f&lt;count($pippo); $f++)
 {
  if($ultimo-&gt;optional = $pippo[$f])
   {
    if($riga == 1)
     {
      print"&lt;tr&gt;"; 
     }
      print"
       &lt;td width='200' class='testo'&gt;
        &lt;input type='checkbox' name='$f' checked='checked'&gt;$pippo[$f]
       &lt;/td&gt;";
       $riga ++;
    if($riga &gt; 2)
     {
      print"&lt;/tr&gt;";
      $riga=1; 
     }
   }
  else
   { 
    if($riga == 1)
     {
      print"&lt;tr&gt;"; 
     }
      print"
       &lt;td width='200' class='testo'&gt;
        &lt;input type='checkbox' name='$f'&gt;$pippo[$f]
       &lt;/td&gt;";
       $riga ++;
    if($riga &gt; 2)
     {
      print"&lt;/tr&gt;";
      $riga=1; 
     }
   }
 }
print"
&lt;/table&gt;";
</code></pre>
<p dir="auto">Ho provato a fare cosi, ma non va, mi da una check ceccata con a fianco scritto array, e poi mi da un errore<br />
<strong>Notice</strong>: Array to string conversion in <strong>D:2_prova.php</strong> on line <strong>105</strong></p>
<p dir="auto">la riga 105 è $pippo=explode(',', $a_optional);</p>
<p dir="auto">Ciao di nuovo</p>
]]></description><link>https://dev.connect.gt/post/965749</link><guid isPermaLink="true">https://dev.connect.gt/post/965749</guid><dc:creator><![CDATA[danny1975]]></dc:creator><pubDate>Sat, 15 Jan 2011 11:53:50 GMT</pubDate></item><item><title><![CDATA[Reply to Checkbox on Sat, 15 Jan 2011 11:29:19 GMT]]></title><description><![CDATA[<p dir="auto">Ciao, grazie per la risposta, ma in questa parte di codice non riesco ad uscirne</p>
<pre><code class="language-php">$query_estr=mysql_query("SELECT * From pippo")
or die("errore nella query;".mysql_error());
$ultimo=mysql_fetch_object($query_estr);
 
$a_optional=array('testo1', 'testo2', 'testo3', 'testo4', 'testo5', 'testo6', 'testo7', 'testo8');
$pippo=explode(',', $a_optional);
print"
&lt;table cellpadding='0' cellspacing='0' border='0' bordercolor='#23D527'&gt;";
$riga=1;
for($f=0; $f&lt;count($a_optional); $f++)
 {
  if($riga == 1)
   {
    print"&lt;tr&gt;"; 
   }
    print"
     &lt;td width='200' class='testo'&gt;
      &lt;input type='checkbox' name='$f'&gt;$a_optional[$f]
     &lt;/td&gt;";
     $riga ++;
  if($riga &gt; 2)
   {
    print"&lt;/tr&gt;";
    $riga=1; 
   }
 }
print"
&lt;/table&gt;";
</code></pre>
<p dir="auto">Ho provato anche con altri esempi e mi riesce, quando lo porto in questo script mi impappino(perdo)<br />
Quando estraggo i dati presenti nella colona optional separati da una virgola, mi dovrebbero apparire nelle check ceccate, ma allo stesso tempo quei dati che fanno parte ugualmente dell'array e non presenti nella colonna optional dovrebbero apparirmi in check non ceccati</p>
<p dir="auto">Ciao e grazie da danny</p>
]]></description><link>https://dev.connect.gt/post/965748</link><guid isPermaLink="true">https://dev.connect.gt/post/965748</guid><dc:creator><![CDATA[danny1975]]></dc:creator><pubDate>Sat, 15 Jan 2011 11:29:19 GMT</pubDate></item><item><title><![CDATA[Reply to Checkbox on Sat, 15 Jan 2011 10:28:41 GMT]]></title><description><![CDATA[<p dir="auto">Ciao danny1975,<br />
gli apici puoi eliminarli da quell'istruzione non sono necessari, da quanto ho capito il campo della tabella è di tipo text, quindi hai i valori separati da virgola pertanto un controllo di questo tipo dovrebbe andare sempre in false, dovresti fare un explode per ottenere i valori in maniera separata e dopo puoi usare la funzione in_array.</p>
]]></description><link>https://dev.connect.gt/post/965747</link><guid isPermaLink="true">https://dev.connect.gt/post/965747</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sat, 15 Jan 2011 10:28:41 GMT</pubDate></item></channel></rss>