<?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[Snellire il codice per renderlo più funzionale]]></title><description><![CDATA[<p dir="auto">Ciao a tutti</p>
<p dir="auto">Volevo sapere se qualcuno sa scrivere in maniera più intelligente questo codice.<br />
Nel database ogni utente ha disposizione la registrazione di 5 set di informazioni, ogni set ha 3 caratteristiche: larghezza (lar), lunghezza (lun) e colore (col).<br />
Quando tutte e tre le caratteristiche dello stesso set combaciano con un set di un altro utente c'è la possibilità di metterli in contatto.</p>
<p dir="auto">Qui sotto posto il codice che ho scritto, che per funzionare funziona, ma non c'è un modo più semplice per fa ciò, in modo anche di non sovraccaricare il server ?</p>
<p dir="auto">Ogni utente nel database ha i campi lar1 lun1 col1 (primo set), lar2 lun2 col2 (secondo set) e cosi via fino a al 5</p>
<p dir="auto">Spero in voi !</p>
<p dir="auto">Ciao !</p>
<p dir="auto">//Verifico se ci sono dati uguali nel primo set;<br />
$sql = "SELECT nick, email FROM utenti where nick&lt;&gt;'$nome_utente' and lar1='$lar1' and lun1='$lun1' and col1='$col1' or nick&lt;&gt;'$nome_utente' and lar2='$lar1' and lun2='$lun1' and col2='$col1' or nick&lt;&gt;'$nome_utente' and lar3='$lar1' and lun3='$lun1' and col3='$col1' or nick&lt;&gt;'$nome_utente' and lar4='$lar1' and lun4='$lun1' and col4='$col1' or nick&lt;&gt;'$nome_utente' and lar5='$lar1' and lun5='$lun1' and col5='$col1'";</p>
<p dir="auto">$row = mysqli_fetch_assoc($result);</p>
<p dir="auto">$result = mysqli_query($cxn,$sql);</p>
<p dir="auto">while($row = mysqli_fetch_row($result))<br />
{<br />
$nick01="$row[0]";<br />
$email01="$row[1]";<br />
}<br />
// segno ok se la verifica ha esito positivo e preparo dati per spedizione messaggio</p>
<pre><code>if($nick01&gt;"0"){
</code></pre>
<p dir="auto">$check1="ok" ;<br />
}<br />
else<br />
{<br />
$check1="ko";}</p>
<p dir="auto">//Verifico se ci sono dati uguali nel secondo set;<br />
$sql = "SELECT nick, email FROM utenti where nick&lt;&gt;'$nome_utente' and lar1='$lar2' and lun1='$lun2' and col1='$col2' or nick&lt;&gt;'$nome_utente' and lar2='$lar2' and lun2='$lun2' and col2='$col2' or nick&lt;&gt;'$nome_utente' and lar3='$lar2' and lun3='$lun2' and col3='$col2' or nick&lt;&gt;'$nome_utente' and lar4='$lar2' and lun4='$lun2' and col4='$col2' or nick&lt;&gt;'$nome_utente' and lar5='$lar2' and lun5='$lun2' and col5='$col2'";</p>
<p dir="auto">$row = mysqli_fetch_assoc($result);</p>
<p dir="auto">$result = mysqli_query($cxn,$sql);</p>
<p dir="auto">while($row = mysqli_fetch_row($result))<br />
{<br />
$nick02="$row[0]";<br />
$email02="$row[1]";<br />
}<br />
// segno ok se la verifica ha esito positivo e preparo dati per spedizione messaggio</p>
<pre><code>if($nick01&gt;"0"){
</code></pre>
<p dir="auto">$check2="ok" ;<br />
}<br />
else<br />
{<br />
$check2="ko";}</p>
<p dir="auto">//Verifico se ci sono dati uguali nel terzo set;<br />
$sql = "SELECT nick, email FROM utenti where nick&lt;&gt;'$nome_utente' and lar1='$lar3' and lun1='$lun3' and col1='$col3' or nick&lt;&gt;'$nome_utente' and lar2='$lar3' and lun2='$lun3' and col2='$col3' or nick&lt;&gt;'$nome_utente' and lar3='$lar3' and lun3='$lun3' and col3='$col3' or nick&lt;&gt;'$nome_utente' and lar4='$lar3' and lun4='$lun3' and col4='$col3' or nick&lt;&gt;'$nome_utente' and lar5='$lar3' and lun5='$lun3' and col5='$col3'";</p>
<p dir="auto">$row = mysqli_fetch_assoc($result);</p>
<p dir="auto">$result = mysqli_query($cxn,$sql);</p>
<p dir="auto">while($row = mysqli_fetch_row($result))<br />
{<br />
$nick03="$row[0]";<br />
$email03="$row[1]";<br />
}<br />
// segno ok se la verifica ha esito positivo e preparo dati per spedizione messaggio</p>
<pre><code>if($nick01&gt;"0"){
</code></pre>
<p dir="auto">$check3="ok" ;<br />
}<br />
else<br />
{<br />
$check3="ko";}</p>
<p dir="auto">//Verifico se ci sono dati uguali nel quarto set;<br />
$sql = "SELECT nick, email FROM utenti where nick&lt;&gt;'$nome_utente' and lar1='$lar4' and lun1='$lun4' and col1='$col4' or nick&lt;&gt;'$nome_utente' and lar2='$lar4' and lun2='$lun4' and col2='$col4' or nick&lt;&gt;'$nome_utente' and lar3='$lar4' and lun3='$lun4' and col3='$col4' or nick&lt;&gt;'$nome_utente' and lar4='$lar4' and lun4='$lun4' and col4='$col4' or nick&lt;&gt;'$nome_utente' and lar5='$lar4' and lun5='$lun4' and col5='$col4'";</p>
<p dir="auto">$row = mysqli_fetch_assoc($result);</p>
<p dir="auto">$result = mysqli_query($cxn,$sql);</p>
<p dir="auto">while($row = mysqli_fetch_row($result))<br />
{<br />
$nick04="$row[0]";<br />
$email04="$row[1]";<br />
}<br />
// segno ok se la verifica ha esito positivo e preparo dati per spedizione messaggio</p>
<pre><code>if($nick01&gt;"0"){
</code></pre>
<p dir="auto">$check4="ok" ;<br />
}<br />
else<br />
{<br />
$check4="ko";}</p>
<p dir="auto">//Verifico se ci sono dati uguali nel quinto set;<br />
$sql = "SELECT nick, email FROM utenti where nick&lt;&gt;'$nome_utente' and lar1='$lar5' and lun1='$lun5' and col1='$col5' or nick&lt;&gt;'$nome_utente' and lar2='$lar5' and lun2='$lun5' and col2='$col5' or nick&lt;&gt;'$nome_utente' and lar3='$lar5' and lun3='$lun5' and col3='$col5' or nick&lt;&gt;'$nome_utente' and lar4='$lar5' and lun4='$lun5' and col4='$col5' or nick&lt;&gt;'$nome_utente' and lar5='$lar5' and lun5='$lun5' and col5='$col5'";</p>
<p dir="auto">$row = mysqli_fetch_assoc($result);</p>
<p dir="auto">$result = mysqli_query($cxn,$sql);</p>
<p dir="auto">while($row = mysqli_fetch_row($result))<br />
{<br />
$nick05="$row[0]";<br />
$email05="$row[1]";<br />
}<br />
// segno ok se la verifica ha esito positivo e preparo dati per spedizione messaggio</p>
<pre><code>if($nick01&gt;"0"){
</code></pre>
<p dir="auto">$check5="ok" ;<br />
}<br />
else<br />
{<br />
$check5="ko";}</p>
]]></description><link>https://dev.connect.gt/topic/52215/snellire-il-codice-per-renderlo-più-funzionale</link><generator>RSS for Node</generator><lastBuildDate>Tue, 01 Dec 2026 07:34:32 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/52215.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Oct 2007 22:13:32 GMT</pubDate><ttl>60</ttl></channel></rss>