<?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[sql- variabile per scegliere la tabella]]></title><description><![CDATA[<p dir="auto">Ciao a tutti,</p>
<p dir="auto">ho un database che contiene una serie di tabelle, io voglio effettuare la ricerca in una di queste tabelle, quindi nel form ho messo un campo per scegliere da quale tabella estrare i risultati, e nell'sql questo :</p>
<p dir="auto">SELECT * FROM 'tabella' WHERE categoria = 'contratto' ORDER BY ID DESC.</p>
<p dir="auto">Pero cosi non funziona, se nvece metto direttamente una tabella , cioè direttamente il nome e non una variabile passata dalla pagina di ricerca, lo script funziona, in cosa sbaglio nell'sql?</p>
<p dir="auto">Spero di essere riuscito a spiegarmi.<br />
Grazie<br />
<img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=gca7n9pp8gc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" title=":)" alt="🙂" /></p>
]]></description><link>https://connect.gt/topic/75484/sql-variabile-per-scegliere-la-tabella</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 13:02:39 GMT</lastBuildDate><atom:link href="https://connect.gt/topic/75484.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 21 Jun 2008 17:23:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sql- variabile per scegliere la tabella on Sat, 21 Jun 2008 18:08:28 GMT]]></title><description><![CDATA[<p dir="auto">Prova a modificare:</p>
<p dir="auto"><strong>$query_Recordset1 = "SELECT * FROM .$_POST['tabella']. WHERE categoria = .$_POST['contratto']. ORDER BY ID DESC";</strong></p>
<p dir="auto">in</p>
<p dir="auto"><strong>$query_Recordset1 = "SELECT * FROM ".$_POST['tabella']." WHERE categoria = ".$_POST['contratto']." ORDER BY ID DESC";</strong></p>
]]></description><link>https://connect.gt/post/729689</link><guid isPermaLink="true">https://connect.gt/post/729689</guid><dc:creator><![CDATA[ceccus]]></dc:creator><pubDate>Sat, 21 Jun 2008 18:08:28 GMT</pubDate></item><item><title><![CDATA[Reply to sql- variabile per scegliere la tabella on Sat, 21 Jun 2008 18:00:57 GMT]]></title><description><![CDATA[<p dir="auto">E quello che ho fatto io ma la pagina rimane bianca.</p>
<p dir="auto">E un sito che sto rifacendo, basato sui comportamenti server di dreamweaver, che tra l'altro non ho fatto io, e sto cercando di seguire la struttura senza dover modificare tutto il codice,ho inserito la quesry sia manuale che col query builder e niente non va, se invece metto invece dela variabile il nome della tabella funziona, possibile che non si puo estrarre il nome di una tabella? seno al liimite provo a riscrivere tuta la pagina che forse faccio prima.<br />
comunque posto il codice creato da dreamweaver:</p>
<pre><code>
&lt;?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_nome, $nomeconnessione);
$query_Recordset1 = "SELECT * FROM .$_POST['tabella']. WHERE categoria = .$_POST['contratto']. ORDER BY ID DESC";
$Recordset1 = mysql_query($query_Recordset1, $nomeconnessione) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?&gt;

</code></pre>
<p dir="auto">piu il codice per richiamare la pagina di connessione.<br />
dici che conviene rifare tutta la pagina?</p>
]]></description><link>https://connect.gt/post/729687</link><guid isPermaLink="true">https://connect.gt/post/729687</guid><dc:creator><![CDATA[kaisersose]]></dc:creator><pubDate>Sat, 21 Jun 2008 18:00:57 GMT</pubDate></item><item><title><![CDATA[Reply to sql- variabile per scegliere la tabella on Sat, 21 Jun 2008 17:42:12 GMT]]></title><description><![CDATA[<p dir="auto">Ciao <em><strong>kaisersose</strong></em>,<br />
supponendo che il campo si chiami <em>nome_tabella</em> e che il form sia inviato mediante POST, dovresti scrivere:</p>
<p dir="auto"><em><strong>$sql = "SELECT * FROM ".$_POST['nome_tabella']." WHERE categoria = 'contratto' ORDER BY ID DESC";</strong></em></p>
<p dir="auto">Facci sapere se così funziona...<br />
<img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/customizations/54a3bffb-5e4a-4eb8-81dc-99b2072e5d05-175.gif?v=gca7n9pp8gc" class="not-responsive emoji emoji-customizations emoji--ciauz" title=":ciauz:" alt=":ciauz:" /></p>
]]></description><link>https://connect.gt/post/729688</link><guid isPermaLink="true">https://connect.gt/post/729688</guid><dc:creator><![CDATA[ceccus]]></dc:creator><pubDate>Sat, 21 Jun 2008 17:42:12 GMT</pubDate></item></channel></rss>