tabla.php
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tablas</title>
</head>
<body>
<?php
$dbhost="localhost";
$dbusuario="root";
$dbpassword="";
$db="escueladb";
$conexion = mysql_connect($dbhost, $dbusuario, $dbpassword);
mysql_select_db($db, $conexion);
$result=mysql_query("SELECT table_name FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'escueladb'",$conexion);
if(!$result)
{
printf("\n<H5>Error al ejecutar '$sentencia': "+mysql_error()+"</H5>");
exit(0);
}
else
{
while($row = mysql_fetch_array($result))
{
?>
<td><p><?php echo $row['table_name'] ?></p></td>
<td align="center"><a href="mostrar-galeria.php?tabla=<?php echo $row['table_name'] ?>">Ampliar</a></td>
</tr>
</tr>
<?php
}
}
mysql_close($conexion);
?>
mostrar-galeria.php
Código PHP:
<?php
$dbhost="localhost";
$dbusuario="root";
$dbpassword="";
$db="escueladb";
$conexion = mysql_connect($dbhost, $dbusuario, $dbpassword);
mysql_select_db($db, $conexion)or die ("Verifique la Base de Datos");
echo "<pre>";
print_r($_GET);
echo "</pre>";
$query =" SELECT * FROM ".$_GET['tabla'] ;
$result = mysql_query($query);
echo "<table>";
if (!$result)
{
$message = 'Error en la consulta: ' . mysql_error() . "\n";
die($message);
}
while($campos = mysql_fetch_array($result))
{
echo "<tr>";
for($i=0;$i<count($campos);$i++)
{
echo "<td>".$campos[$i]."</td";
}
echo "</tr>";
}
echo "</table>";
?>