Codice PHP:
else { echo "Campi che si stà mostrando: [b]".$getFieldCountShow."[/b] | "; }
echo "Go To: [b]<a href=\"#GetTableNames\">Lista tabella</a>[/b]</td></tr>";
$printTD = "<td align=\"center\" valign=\"top\" class=\"G\">Row
#</td>"; // prints all TDs that hold all the field names across the top
$printTDp = ""; // string to print Primary Key or No Primary Key defined
$printTDq = "0"; // if this changes, then a primary key has been found - else there is no primary key
$printTD1 = "<tr><td align=\"center\"></td>"; // this will change if no primary key is found
$printTDh = ""; // this will hold the field name if a primary key is found
for ($icnt=0; $icnt<$getFieldCount; $icnt++)
{ $meta = mysql_fetch_field($getDataQuery, $icnt);
if ($icnt<$getFieldCountShow)
{ if ($meta->primary_key == "1")
{ $printTDq = "1";
$printTDh = $meta->name;
$printTDp .= "
<small style=\"color:Maroon;\">Chiave primaria</small>"; }
else { $printTDp = ""; }
$printTD = $printTD . "<td valign=\"top\">[b]$meta->name[/b]".$printTDp. "</td>";
} else {
if ($meta->primary_key == "1")
{ $printTDq = "2";
$printTDh = $meta->name; }
}
}
if ($printTDq == "0")
{ $printTD1 = "<tr><td align=\"center\"><small style=\"color:Maroon;\">Nessuna
chiave definita</small></td>"; }
elseif ($printTDq == "2")
{ $printTD1 = "<tr><td align=\"center\"><small style=\"color:Maroon;\">Chiave primaria
trovata fuori luogo</small></td>"; }
echo $printTD1 . $printTD;
echo "</tr>";
if (isset($_POST["GetTableListRecordS"]) && ((int)$_POST["GetTableListRecordS"])>0)
{ $printTDcnt = (int)$_POST["GetTableListRecordS"]; }
else { $printTDcnt = 1; }
while($row = mysql_fetch_array($getDataQuery))
{ echo "<form name=\"GetItForm\" action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
echo "<tr>";
if ($readyFor=="1")
{ echo "<td align=\"center\"><input type=\"submit\" value=\"Modifica\" name=\"GetIt\"></td>"; }
elseif ($readyFor =="3")
{ echo "<td align=\"center\"><input type=\"submit\" value=\"Modifica\" name=\"GetIt\"><input type=\"submit\" value=\"Cancella\" name=\"GetIt\" onClick=\"return returnconfirm('Cancellare?');\"></td>"; }
elseif ($readyFor == "7")
{ echo "<td align=\"center\"><input type=\"submit\" value=\"Ed\" name=\"GetIt\"><input type=\"submit\" value=\"Cp\" name=\"GetIt\"><input type=\"submit\" value=\"X\" name=\"GetIt\" onClick=\"return returnconfirm('Delete?');\"></td>"; }
echo "<td align=\"center\" class=\"G\">".$printTDcnt."</td>";
echo "<input type=\"hidden\" name=\"GetTableName\" value=\"".$tablename."\">";
echo "<input type=\"hidden\" name=\"GetTableListFieldCount\" value=\"".$_POST["GetTableListFieldCount"]."\">";
echo "<input type=\"hidden\" name=\"GetTableListRecordS\" value=\"".$_POST["GetTableListRecordS"]."\">";
echo "<input type=\"hidden\" name=\"GetTableListRecordT\" value=\"".$_POST["GetTableListRecordT"]."\">";
echo "<input type=\"hidden\" name=\"FieldUniqueName\" value=\"".$printTDh."\">";
for ($icnt=0; $icnt<$getFieldCount; $icnt++)
{ if ($icnt<$getFieldCountShow)
{ if ($row[$icnt] == "")
{ echo "<td></td>"; } else
{ echo "<td>" . $row[$icnt] . "</td>"; }
}
if (mysql_field_name($getDataQuery, $icnt) == $printTDh)
{ echo "<input type=\"hidden\" name=\"FieldUniqueData\" value=\"".$row[$icnt]."\">"; }
}
echo "</tr></form>";
$printTDcnt = $printTDcnt + 1;
}
echo "</tr></table>";
echo "<hr size=\"3\" color=\"Navy\" noshade>";
}
else
{ if (isset($_POST["GetTableListRecordS"]) && ((int)$_POST["GetTableListRecordS"])>1)
{ echo "
Non ci sono record da mostrare in questa tabella ...
Tuttavia, la riga di partenza potrebbe essere superiore al numero di record nella tabella...
<hr size=\"3\" color=\"Navy\" noshade></P>"; }
else { echo "
Non ci sono record da mostrare in questa tabella ...
<hr size=\"3\" color=\"Navy\" noshade></P>"; }
}
mysql_free_result($getDataQuery);
}
if ((isset($_POST["GetTableListSubmit"]))&&(empty($_POST["GetTableName"])))
{ echo "
Scegliere un database!
<hr size=\"3\" color=\"Navy\" noshade></P>"; }
$getTableQuery = mysql_list_tables($databasename, $connectstring);
if ($tableDefHgt=="0") { $getTableCount = mysql_num_rows($getTableQuery)+1; }
else { $getTableCount = $tableDefHgt; }
if (mysql_num_rows($getTableQuery)>0)
{ echo "</td></tr><form name=\"GetTableForm\" action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
echo "<tr><td align=\"center\" valign=\"top\">";
echo "[b]Seleziona la tabella[/b]<a name=\"GetTableNames\"></a>
";
echo "<select name=\"GetTableName\" id=\"GetTableName\" size=\"".$getTableCount."\" onClick=\"GetTableListSubmit.focus();\">";
$gotIt = "1";
while($tablerow = mysql_fetch_array($getTableQuery))
{ if (
($tableFilter=="") ||
($tableFilter!="" && $FilterToggle=="show" && stripos($tablerow[0],$tableFilter)!==FALSE) || // cont.- Show table names
($tableFilter!="" && $FilterToggle=="hide" && stripos($tablerow[0],$tableFilter)===FALSE) // skip - Hide table names
)
{ if (($tableDef!="")&&($tableDef==$tablerow[0]))
{ echo "<option value=\"".$tablerow[0]."\" selected>".$tablerow[0]."</option>"; $gotIt="2"; }
else { echo "<option value=\"".$tablerow[0]."\">".$tablerow[0]."</option>"; }
}
}
echo "</select>";
if (($tableDefSet!="")&&($gotIt=="1")) { echo "
<font color=\"Maroon\">Tabella</font> [ [b]$tableDefSet[/b] ]
Modifica nel 'dbconnect.php'
file <font color=\"Maroon\">inesistente</font>"; }
echo "</td>";
echo "<td></td>";
echo "<td valign=\"top\">
";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\"><tr>";
echo "<td align=\"left\" valign=\"top\" colspan=\"2\">";
if (isset($_POST["GetTableListFieldCount"]))
{ echo "[b]Numero di campi[/b]
(colonne) da mostrare
<input type=\"text\" name=\"GetTableListFieldCount\" id=\"GetTableListFieldCount\" size=\"5\" value=\"".$_POST["GetTableListFieldCount"]."\" onblur=\"return isNum(this);\">"; }
else { echo "[b]Numero di campi[/b]
(colonne) da mostrare
<input type=\"text\" name=\"GetTableListFieldCount\" id=\"GetTableListFieldCount\" size=\"5\" value=\"4\" onblur=\"return isNum(this);\">"; }
if (isset($getFieldCount)) { echo "<strong style=\"color:silver;font-weight:normal;\">out of <strong style=\"color:silver;\">".$getFieldCount."[/b][/b]"; }
echo "</td></tr>";
echo "<tr><td align=\"left\" valign=\"top\">";
if (isset($_POST["GetTableListRecordS"]) && $_POST["GetTableListRecordS"]!="")
{ echo "[b]Partenza numero righe[/b]
<input type=\"text\" name=\"GetTableListRecordS\" id=\"GetTableListRecordS\" size=\"5\" value=\"".$_POST["GetTableListRecordS"]."\" onblur=\"return isNum(this);\">"; }
else { echo "[b]Partenza numero righe[/b]
(empty, 0, 1: beginning)
<input type=\"text\" name=\"GetTableListRecordS\" id=\"GetTableListRecordS\" size=\"5\" value=\"1\" onblur=\"return isNum(this);\">"; }
echo "</td><td align=\"left\" valign=\"top\">";
if (isset($_POST["GetTableListRecordT"]) && $_POST["GetTableListRecordT"]!="")
{ echo "[b]Numero di righe[/b]
da mostrare <input type=\"text\" name=\"GetTableListRecordT\" id=\"GetTableListRecordT\" size=\"5\" value=\"".$_POST["GetTableListRecordT"]."\" onblur=\"return isNum(this);\">"; }
else { echo "[b]Numero di righe[/b]
da mostrare (empty or 0: all remaining)
<input type=\"text\" name=\"GetTableListRecordT\" id=\"GetTableListRecordT\" size=\"5\" value=\"0\" onblur=\"return isNum(this);\">"; }
echo "</td>";
$GetTableListFieldCountText = <<<GetTableListFieldCountText
<small class="x">
Se i record presenti nella tabella, la tabella risultante viene visualizzato sia il numero di campi, o tutti i campi della tabella, se inferiore.
Numero deve essere maggiore di 0 e minore o uguale a 99. Tutto il resto, come ad esempio 0, produrrà tutti i campi della tabella non importa quanti campi ci sono.
</small>
GetTableListFieldCountText;
echo "</tr><tr><td colspan=\"3\" align=\"left\" valign=\"top\">".$GetTableListFieldCountText;
echo "
<input type=\"submit\" name=\"GetTableListSubmit\" value=\"Mostra record\">";
echo "</form>";
echo "</td>";
echo "</tr></table>";
}
function addAslash($str)
{ if (get_magic_quotes_gpc()==1)
{ return ($str); }
else
{ return (addslashes($str)); }
}
mysql_free_result($getTableQuery);
?>
</td></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="right">
<tr><td><hr color="Maroon" size="1"></td></tr>
<tr><td align="right">
<small class="xg">[url="http://facebook.com/ottyteo"]Matteo Ottella[/url]</small>
</td></tr>
</table>
</body>