<?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[[MySQL] Come gestire campi con valori &quot;0&quot; e &quot;1&quot; ?]]></title><description><![CDATA[<p dir="auto">Buona sera,<br />
apro questo Thread per avere un consiglio sulla tecnica da adottare per gestire la visualizzazione di alcuni campi di una tabella mysql che posson avere come valore solo "0" o "1".<br />
La mia tabella è cosi strutturata:<br />
nome_campo_1 (0)<br />
nome_campo_2 (0)<br />
nome_abbreviato_campo_3 (1)<br />
ecc...ecc</p>
<p dir="auto">Quello che vorrei realizzare è questo: <em>Stampami solo <strong>il nome</strong> dei campi con valore "1" modificandone il nome da stampare</em>.<br />
come vedete il nome di ogni campo è del tipo "nome_altronome_campo_numero". Come posso fare a resituire il titolo del campo o ad attribuire ad ogni campo una stringa predefinita con un "define()" ?</p>
<p dir="auto">Il mio scopo è quello di fare vedere le scelte (quindi i campi checcati a "1") effettuate da ogni utente.</p>
<p dir="auto">Grazie.</p>
]]></description><link>https://dev.connect.gt/topic/142044/mysql-come-gestire-campi-con-valori-quot-0-quot-e-quot-1-quot</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 11:59:20 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/142044.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Dec 2010 17:27:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [MySQL] Come gestire campi con valori &quot;0&quot; e &quot;1&quot; ? on Mon, 03 Jan 2011 08:36:38 GMT]]></title><description><![CDATA[<p dir="auto">A dire il vero continuo a non capire bene ma se utilizzi mysql_fetch_assoc puoi fare una cosa del genere:</p>
<pre><code class="language-php">&lt;?php

// ... ti sei già connesso al db etc. etc.

while ($row = mysql_fetch_assoc($result)) {
    foreach ($row as $nome_campo =&gt; $valore) {
        // qui per ogni riga scorri tutti i campi avendo il nome del campo e il valore (cioè 0 o 1, se capisco bene)
        // e puoi quindi decidere cosa mostrare etc.
    }
}

?&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/959118</link><guid isPermaLink="true">https://dev.connect.gt/post/959118</guid><dc:creator><![CDATA[html5today]]></dc:creator><pubDate>Mon, 03 Jan 2011 08:36:38 GMT</pubDate></item><item><title><![CDATA[Reply to [MySQL] Come gestire campi con valori &quot;0&quot; e &quot;1&quot; ? on Fri, 31 Dec 2010 09:18:20 GMT]]></title><description><![CDATA[<p dir="auto">Il mio problema è attribuire ad ogni campo=1 un titolo.<br />
Cioè dovrei riuscire a scorrere di pari passo due array: un array contenente i valori che devo mostrare e un altro array contenente "1" o "0".<br />
Forse sono stato poco chiaro nel post di apertura: ho una tabella con una serie di campi che possono avere come valore "1" o "0" e restituire un determinato nome solo se il campo è 1.<br />
In pratica come funzionano tutte le tabelle che mostrano le scelte effettuate da un utente.</p>
]]></description><link>https://dev.connect.gt/post/959121</link><guid isPermaLink="true">https://dev.connect.gt/post/959121</guid><dc:creator><![CDATA[tarab]]></dc:creator><pubDate>Fri, 31 Dec 2010 09:18:20 GMT</pubDate></item><item><title><![CDATA[Reply to [MySQL] Come gestire campi con valori &quot;0&quot; e &quot;1&quot; ? on Thu, 30 Dec 2010 22:36:48 GMT]]></title><description><![CDATA[<p dir="auto">Puoi utilizzare mysql_fetch_assoc (o qualcosa di simile, non so quale libreria usi per accedere al DB) e visto che ogni riga ti viene ritornata come un array associativo scorrere tutti i campi scegliendo quelli che hanno un valore pari a 1</p>
]]></description><link>https://dev.connect.gt/post/959117</link><guid isPermaLink="true">https://dev.connect.gt/post/959117</guid><dc:creator><![CDATA[html5today]]></dc:creator><pubDate>Thu, 30 Dec 2010 22:36:48 GMT</pubDate></item><item><title><![CDATA[Reply to [MySQL] Come gestire campi con valori &quot;0&quot; e &quot;1&quot; ? on Thu, 30 Dec 2010 11:26:08 GMT]]></title><description><![CDATA[<p dir="auto">nessuno che sappia darmi un'idea?</p>
]]></description><link>https://dev.connect.gt/post/959120</link><guid isPermaLink="true">https://dev.connect.gt/post/959120</guid><dc:creator><![CDATA[tarab]]></dc:creator><pubDate>Thu, 30 Dec 2010 11:26:08 GMT</pubDate></item></channel></rss>