pense ke era algo simple, pero bien aqui el codigo!
Código PHP:
Ver original<?php require_once('Connections/comentarios.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO comentarios (autor, comentario) VALUES (%s, %s)", GetSQLValueString($_POST['autor'], "text"),
GetSQLValueString($_POST['comentario'], "text"));
$insertGoTo = "coemntarios.php";
if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ?
"&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO comentarios (fecha, autor, comentario) VALUES (%s, %s, %s)", GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['autor'], "text"),
GetSQLValueString($_POST['comentario'], "text"));
}
$maxRows_comentarios = 10;
$pageNum_comentarios = 0;
if (isset($_GET['pageNum_comentarios'])) { $pageNum_comentarios = $_GET['pageNum_comentarios'];
}
$startRow_comentarios = $pageNum_comentarios * $maxRows_comentarios;
$query_comentarios = "SELECT * FROM comentarios ORDER BY ID_comentario DESC";
$query_limit_comentarios = sprintf("%s LIMIT %d, %d", $query_comentarios, $startRow_comentarios, $maxRows_comentarios);
if (isset($_GET['totalRows_comentarios'])) { $totalRows_comentarios = $_GET['totalRows_comentarios'];
} else {
}
$totalPages_comentarios = ceil($totalRows_comentarios/$maxRows_comentarios)-1; ?>
<!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>
<div>
<p> </p>
<div>
<div>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Autor:</td>
<td><input type="text" name="autor" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Comentario:</td>
<td><textarea name="comentario" cols="32" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insertar registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</div>
</div>
<p> </p>
<div>
<table width="290" border="5" align="center" cellspacing="20">
<?php do { ?>
<tr>
<td width="176" height="29"><?php echo $row_comentarios['autor']; ?> dijo...</td>
</tr>
<tr>
<td height="95" align="left" valign="top"><?php echo $row_comentarios['comentario']; ?></td>
</tr>
<tr>
<td><?php echo $row_comentarios['fecha']; ?></td>
</tr>
</table>
</div>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
</body>
</html>
<?php
?>