<?php
/*************************************************************
* The MyDB librairy and applications are product of SQLFusion
* It may be used and/or distributed under the terms of the Q Public
* License (QPL) version 1.0, enclosed in the file licence.txt.
****************************************************************/
/** MyDB IDE Version 0.4 **/
/** Author Philippe Lewicki **/
/* Project Mydata Lib Philippe Lewicki 06/08/1999 */
require("mydbconfig.inc.php");
$connect = new mydataconnect;
$connect->start();
$connect->db = $db ;
$DispTable = new mydataTable;
$DispTable->cfgBgcolorOne = "#D0F5C5" ;
$DispTable->cfgBgcolorTwo = "#C7F5E7" ;
$menu = "query" ;
include("hd_inc.php");
?>
<TABLE width="400" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><TD width="15" height="25" align="center">
||
</td><TD width="370" height="25" bgcolor="#ffcc33" align="center" class="titrearticle">
<? echo $strLinkTablesOf." : ".$tablename ; ?>
</td><TD width="15" height="25" align="center">
||
</td>
</tr>
</table><BR>
<?
if (isset($wherequery)) {
$wherequery = stripslashes($wherequery) ;
list ($name_key, $num_key) = explode("=", $wherequery) ;
/* echo "--".$name_key."-=-".$num_key."-" ;*/
}
$tablelinked = $table ;
$tables = mysql_list_tables($db);
$num_tables = @mysql_numrows($tables);
$j = 0;
echo "<table border=$DispTable->cfgBorder>\n";
echo "<th> </th>";
echo "<th > </th>";
$bgcolor = $DispTable->cfgBgcolorOne;
$i % 2 ? 0: $bgcolor = $DispTable->cfgBgcolorTwo;
while ($j < $num_tables)
{
$table = mysql_tablename($tables, $j);
$connect->table = $table ;
if ($table == $tablelinked) { echo $table." :"; } else {
$result = mysql_db_query($db, "SHOW KEYS FROM ".$table);
if (!$result)
{
mysql_die();
}
else
{
if (mysql_num_rows($result)>0)
{ $linked = "No" ;
for ($i=0 ; $i<mysql_num_rows($result); $i++)
{
$row = mysql_fetch_array($result);
// echo $name_key."==".$row["Column_name"];
if ($row["Column_name"] == $name_key) // Vérifie si on trouve la clé primaire dans cette table.
{
$linked = "Yes" ;
}
if ($row["Key_name"] == "PRIMARY") // on récuper la clé primaire de cette table.
{
$name_key2 = $row["Column_name"] ;
}
} // fin du for on a passé toute les clés en revue
if ($linked == "Yes") {
// Teste une selection sur la table. Est elle vide pour la clé primaire
$restest = mysql_db_query($db, "select * from $table where $wherequery") ;
// On affiche le nom de la table avec un lien sur l'affichage de sont contenu ou l'insertion d'un nouvelle enregistrement
?>
<tr bgcolor="<?php echo $bgcolor;?>">
<td> <b><?php echo $table; ?> </b></td>
<?
$query = "?db=$db&table=$table&goto=".urlencode($GLOBALS[REQUEST_URI])."&secondary_key=$wherequery";
if (!($restest) || !(mysql_num_rows($restest)>0)) {
?>
<td>
<!--- <a href="<?php echo $cfgAddPage.$query;?>"><?php echo $strInsertNewRow; ?>One</a></td> --->
<?
} else {
// affichage de la table
echo "\n<td>" ;
$DispTable->cfgAddRecord = false ;
$DispTable->cfgOrderTable = false ;
$DispTable->cfgLinkTableRecord = true;
$DispTable->displaytable($connect, $restest);
?>
<a href="<?php echo $cfgAddPage.$query;?>"><?php echo $strInsertNewRow; ?></a></td>
<?
}
} // fin du linked
} //fin du if numrows
} // fin du else result
} // fin de la table différente de table linked
echo "\n</tr>\n" ;
$j++;
} // fin du while table
echo "</table>\n";
include("ft_inc.php");
?>