Código PHP:
<?php
if($_GET[id] == "") {
include("modulos/inicio.php");
} else {
if(file_exists("modulos/".$_GET[id].".php")) {
include("modulos/".$_GET[id].".php");
} else {
include("modulos/error.php");
}
}
?>
Ahora llamo a una pagina que se llama producto.php y hago una consulta para que me muestre los datos basicos de la tabla como nombre y valor y creo un link que se llama Detalles , pero al hacer clic en este enlace me da, debido a que la configuracion $_GET[id] no me la reconoce, pues no esta entre sus parametros, COMO HAGO PARA QUE ESTO ME FUNCIONE, COMO HAGO PARA QUE UNA WEB MODULAR ME ACEPTE ESTOS PROCEDIMIENTOS?.
producto.php
Código PHP:
<?php require_once('conexion.php'); ?>
<?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_conexion, $conexion);
$query_producto = "SELECT * FROM productos";
$producto = mysql_query($query_producto, $conexion) or die(mysql_error());
$row_producto = mysql_fetch_assoc($producto);
$totalRows_producto = mysql_num_rows($producto);
?><!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>Documento sin título</title>
</head>
<body>
<table width="513">
<tr>
<td><?php echo $row_producto['nombre']; ?></td>
</tr>
<tr>
<td><?php echo $row_producto['valor']; ?></td>
</tr>
</table>
<p><a href="index.php?id=detalles.php?id=<?php echo$row_producto[id];?>">Detalles</a></p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($producto);
?>
Código PHP:
<?php require_once('conexion.php'); ?>
<?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;
}
}
$colname_detalles = "-1";
if (isset($_GET['id'])) {
$colname_detalles = $_GET['id'];
}
mysql_select_db($database_conexion, $conexion);
$query_detalles = sprintf("SELECT * FROM productos WHERE id = %s", GetSQLValueString($colname_detalles, "int"));
$detalles = mysql_query($query_detalles, $conexion) or die(mysql_error());
$row_detalles = mysql_fetch_assoc($detalles);
$totalRows_detalles = mysql_num_rows($detalles);
?><!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>Documento sin título</title>
</head>
<body>
<table>
<tr>
<td width="477"><?php echo $row_detalles['nombre']; ?></td>
</tr>
<tr>
<td><?php echo $row_detalles['descripcion']; ?></td>
</tr>
<tr>
<td><?php echo $row_detalles['valor']; ?></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($detalles);
?>
http://localhost:8082/modu/index.php?id=detalles.php?id=1