<?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[mostrare solo una volta un testo nel ciclo while]]></title><description><![CDATA[<p dir="auto">Salve a tutti<br />
sto cercando di mostrare una gallery di alcuni alberghi usando fancybox.<br />
Il problema è che per costruire la struttura esatta per poi mostrare le foto, devo mettere tutto in un ciclo while, compreso il link per l'apertura delle foto.</p>
<p dir="auto">Con il mio codice se ho 10 foto, mostro 10 volte la scritta "VEDI FOTO"</p>
<p dir="auto">Come posso fare a mostrare solo una volta il link?<br />
Ecco il codice</p>
<pre><code>$query_fotogallery="select * from foto_hotel where id_hotel=\"$riga[id_hotel]\" and attiva=\"1\"";
$risultato_fotogallery = @mysql_query($query_fotogallery) or die("Impossibile eseguire l'interrogazione fotogallery"); 
while ($riga_fotogallery = mysql_fetch_array($risultato_fotogallery)) {
$id_hotel = $riga_fotogallery['id_hotel'];
$id_foto = $riga_fotogallery['id_foto'];
$fotogallery = $riga_fotogallery['foto'];
$mostra_gallery="&lt;a class=\"fancybox\" rel=\"gallery1\" href=\"$url/foto-strutture/$directory/grandi/thumb2_$fotogallery\"&gt;VEDI FOTO&lt;/a&gt;";
echo"$mostra_gallery&lt;br&gt;";
}
</code></pre>
<p dir="auto">Come posso risolvere?<br />
Grazie</p>
]]></description><link>https://dev.connect.gt/topic/233905/mostrare-solo-una-volta-un-testo-nel-ciclo-while</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 04:47:29 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/233905.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Mar 2018 00:41:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to mostrare solo una volta un testo nel ciclo while on Tue, 27 Mar 2018 19:52:41 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto"><strong>No_Stress</strong></p>
<p dir="auto">ci siamo quasi, funziona bene il tuo metodo, solo che adesso appena si apre la gallery le prime 2 foto sono le stesse, poi iniziano tutte le altre e questo per ogni struttura</p>
<p dir="auto">Quindi per esempio:<br />
hotel x: prima foto quella della piscina, seconda foto la stessa, dalla terza in poi tutte foto nuove</p>
<p dir="auto">e questo per tutte le altre strutture</p>
<p dir="auto">Come potrei fare ad evitare di far visualizzare la stessa foto 2 volte?</p>
<p dir="auto">Ecco il codice aggiornato con il tuo consiglio:</p>
<pre><code class="language-php">$show = true;
$query_fotogallery="select * from foto_hotel where id_hotel=\"$riga[id_hotel]\" and attiva=\"1\"";
$risultato_fotogallery = @mysql_query($query_fotogallery) or die("Impossibile eseguire l'interrogazione fotogallery"); 
//$numero_foto_gallery = mysql_num_rows($risultato_fotogallery);
while ($riga_fotogallery = mysql_fetch_array($risultato_fotogallery)) {
$id_hotel = $riga_fotogallery['id_hotel'];
$id_foto = $riga_fotogallery['id_foto'];
$fotogallery = $riga_fotogallery['foto'];
if($show == true) {
$mostra_gallery="&lt;a class=\"fancybox\" rel=\"gallery1\" href=\"$url/foto-strutture/$directory/grandi/thumb2_$fotogallery\"&gt;&lt;button type=\"button\" class=\"btn btn-info btn-sm\" style=\"margin-top:5px;\"&gt;&lt;b&gt;VEDI FOTO&lt;/b&gt;&lt;/button&gt;&lt;/a&gt;";
echo"$mostra_gallery";
}
$show = false;
$mostra_gallery="&lt;a class=\"fancybox\" rel=\"gallery1\" href=\"$url/foto-strutture/$directory/grandi/thumb2_$fotogallery\"&gt;&lt;/a&gt;";
echo"$mostra_gallery";
}
</code></pre>
<p dir="auto">Inoltre ho notato che una volta che arrivo all'ultima foto dell'hotel, non ricomincia da zero, ma fa vedere le foto dell'albergo successivo e questo è un problema<br />
E' risolvibile? Magari devo fare qualche altro controllo...<br />
Grazie</p>
</blockquote>
<p dir="auto">Tu avevi detto di voler mostrare una sola volta il VEDI FOTO quindi nel while non devi riportarci tutto il mostra gallery ma solo il vedi foto. Cioè il tuo codice andrebbe modificato così:</p>
<pre><code class="language-php">$show = true;
$query_fotogallery="select * from foto_hotel where id_hotel=\"$riga[id_hotel]\" and attiva=\"1\"";
$risultato_fotogallery = @mysql_query($query_fotogallery) or die("Impossibile eseguire l'interrogazione fotogallery"); 
//$numero_foto_gallery = mysql_num_rows($risultato_fotogallery);
while ($riga_fotogallery = mysql_fetch_array($risultato_fotogallery)) {
$id_hotel = $riga_fotogallery['id_hotel'];
$id_foto = $riga_fotogallery['id_foto'];
$fotogallery = $riga_fotogallery['foto'];
$mostra_gallery="&lt;a class=\"fancybox\" rel=\"gallery1\" href=\"$url/foto-strutture/$directory/grandi/thumb2_$fotogallery\"&gt;";
echo"$mostra_gallery";
if($show == true) {
&lt;button type=\"button\" class=\"btn btn-info btn-sm\" style=\"margin-top:5px;\"&gt;&lt;b&gt;VEDI FOTO&lt;/b&gt;&lt;/button&gt;&lt;/a&gt;";
$show = false;
}
}
</code></pre>
<p dir="auto">L'ultimo problema non l'ho capito visto che non conosco tutto il funzionamento.</p>
]]></description><link>https://dev.connect.gt/post/1247261</link><guid isPermaLink="true">https://dev.connect.gt/post/1247261</guid><dc:creator><![CDATA[eduadie]]></dc:creator><pubDate>Tue, 27 Mar 2018 19:52:41 GMT</pubDate></item><item><title><![CDATA[Reply to mostrare solo una volta un testo nel ciclo while on Wed, 21 Mar 2018 00:52:06 GMT]]></title><description><![CDATA[<p dir="auto">ci siamo quasi, funziona bene il tuo metodo, solo che adesso appena si apre la gallery le prime 2 foto sono le stesse, poi iniziano tutte le altre e questo per ogni struttura</p>
<p dir="auto">Quindi per esempio:<br />
hotel x: prima foto quella della piscina, seconda foto la stessa, dalla terza in poi tutte foto nuove</p>
<p dir="auto">e questo per tutte le altre strutture</p>
<p dir="auto">Come potrei fare ad evitare di far visualizzare la stessa foto 2 volte?</p>
<p dir="auto">Ecco il codice aggiornato con il tuo consiglio:</p>
<pre><code class="language-php">$show = true;
$query_fotogallery="select * from foto_hotel where id_hotel=\"$riga[id_hotel]\" and attiva=\"1\"";
$risultato_fotogallery = @mysql_query($query_fotogallery) or die("Impossibile eseguire l'interrogazione fotogallery"); 
//$numero_foto_gallery = mysql_num_rows($risultato_fotogallery);
while ($riga_fotogallery = mysql_fetch_array($risultato_fotogallery)) {
$id_hotel = $riga_fotogallery['id_hotel'];
$id_foto = $riga_fotogallery['id_foto'];
$fotogallery = $riga_fotogallery['foto'];
if($show == true) {
$mostra_gallery="&lt;a class=\"fancybox\" rel=\"gallery1\" href=\"$url/foto-strutture/$directory/grandi/thumb2_$fotogallery\"&gt;&lt;button type=\"button\" class=\"btn btn-info btn-sm\" style=\"margin-top:5px;\"&gt;&lt;b&gt;VEDI FOTO&lt;/b&gt;&lt;/button&gt;&lt;/a&gt;";
echo"$mostra_gallery";
}
$show = false;
$mostra_gallery="&lt;a class=\"fancybox\" rel=\"gallery1\" href=\"$url/foto-strutture/$directory/grandi/thumb2_$fotogallery\"&gt;&lt;/a&gt;";
echo"$mostra_gallery";
}
</code></pre>
<p dir="auto">Inoltre ho notato che una volta che arrivo all'ultima foto dell'hotel, non ricomincia da zero, ma fa vedere le foto dell'albergo successivo e questo è un problema<br />
E' risolvibile? Magari devo fare qualche altro controllo...<br />
Grazie</p>
]]></description><link>https://dev.connect.gt/post/1247266</link><guid isPermaLink="true">https://dev.connect.gt/post/1247266</guid><dc:creator><![CDATA[no.stress]]></dc:creator><pubDate>Wed, 21 Mar 2018 00:52:06 GMT</pubDate></item><item><title><![CDATA[Reply to mostrare solo una volta un testo nel ciclo while on Tue, 20 Mar 2018 18:49:30 GMT]]></title><description><![CDATA[<p dir="auto">fuori dal ciclo while la setti true, fai un controllo all'interno che scrive VEDI FOTO solo se la variabile è settata true. Ma a fine ciclo la imposti false in modo che non sarà mai true ma solo la prima volta.</p>
<pre><code class="language-php">$show = true;
while () {
if($show == true) {
VEDI FOTO
}

//Tutto quello che ti serve

$show = false;
}
</code></pre>
]]></description><link>https://dev.connect.gt/post/1247260</link><guid isPermaLink="true">https://dev.connect.gt/post/1247260</guid><dc:creator><![CDATA[eduadie]]></dc:creator><pubDate>Tue, 20 Mar 2018 18:49:30 GMT</pubDate></item><item><title><![CDATA[Reply to mostrare solo una volta un testo nel ciclo while on Tue, 20 Mar 2018 12:22:24 GMT]]></title><description><![CDATA[<p dir="auto">si ma se lo metto fuori dal while poi non mostra tutto il resto, in pratica dovrei mostrare qualcosa tipo:</p>
<p dir="auto">$mostra_gallery="&lt;a class="fancybox" rel="gallery1" href="$url/foto-strutture/$directory/grandi/thumb2_$foto1"&gt;VEDI FOTO&lt;/a&gt;";<br />
$mostra_gallery="&lt;a class="fancybox" rel="gallery1" href="$url/foto-strutture/$directory/grandi/thumb2_$foto2"&gt;&lt;/a&gt;";<br />
$mostra_gallery="&lt;a class="fancybox" rel="gallery1" href="$url/foto-strutture/$directory/grandi/thumb2_$foto3"&gt;&lt;/a&gt;";<br />
$mostra_gallery="&lt;a class="fancybox" rel="gallery1" href="$url/foto-strutture/$directory/grandi/thumb2_$foto4"&gt;&lt;/a&gt;";<br />
$mostra_gallery="&lt;a class="fancybox" rel="gallery1" href="$url/foto-strutture/$directory/grandi/thumb2_$foto5"&gt;&lt;/a&gt;";</p>
<p dir="auto">ecc</p>
<p dir="auto">come dovrei fare con la variabile settata su true e false?</p>
]]></description><link>https://dev.connect.gt/post/1247265</link><guid isPermaLink="true">https://dev.connect.gt/post/1247265</guid><dc:creator><![CDATA[no.stress]]></dc:creator><pubDate>Tue, 20 Mar 2018 12:22:24 GMT</pubDate></item><item><title><![CDATA[Reply to mostrare solo una volta un testo nel ciclo while on Tue, 20 Mar 2018 12:18:59 GMT]]></title><description><![CDATA[<p dir="auto">Bhè se lo vuoi mostrare solo una volta lo metti fuori dal while, altrimenti lo mostri la prima volta con un controllo su di una variabile $show settata inizialmente a true dopodichè passa a false e non dovrebbe più passare il controllo.</p>
]]></description><link>https://dev.connect.gt/post/1247259</link><guid isPermaLink="true">https://dev.connect.gt/post/1247259</guid><dc:creator><![CDATA[eduadie]]></dc:creator><pubDate>Tue, 20 Mar 2018 12:18:59 GMT</pubDate></item></channel></rss>