Tema: Consulta
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/08/2010, 15:39
cienporcientoweb
Usuario no validado
 
Fecha de Ingreso: febrero-2008
Ubicación: Montevideo
Mensajes: 142
Antigüedad: 16 años, 2 meses
Puntos: 7
Respuesta: Consulta

hola disculpen este es el codigo :
Cita:
<?php require_once('Connections/casuringa.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$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 (id_comentarios, comentarios, fecha, Usuario) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['id_comentarios'], "int"),
GetSQLValueString($_POST['comentarios'], "text"),
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['Usuario'], "text"));

mysql_select_db($database_casuringa, $casuringa);
$Result1 = mysql_query($insertSQL, $casuringa) or die(mysql_error());

$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

$maxRows_comentarios = 10;
$pageNum_comentarios = 0;
if (isset($_GET['pageNum_comentarios'])) {
$pageNum_comentarios = $_GET['pageNum_comentarios'];
}
$startRow_comentarios = $pageNum_comentarios * $maxRows_comentarios;

mysql_select_db($database_casuringa, $casuringa);
$query_comentarios = "SELECT comentarios, Usuario FROM comentarios";
$query_limit_comentarios = sprintf("%s LIMIT %d, %d", $query_comentarios, $startRow_comentarios, $maxRows_comentarios);
$comentarios = mysql_query($query_limit_comentarios, $casuringa) or die(mysql_error());
$row_comentarios = mysql_fetch_assoc($comentarios);

if (isset($_GET['totalRows_comentarios'])) {
$totalRows_comentarios = $_GET['totalRows_comentarios'];
} else {
$all_comentarios = mysql_query($query_comentarios);
$totalRows_comentarios = mysql_num_rows($all_comentarios);
}
$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=iso-8859-1" />
<title>comentarios</title>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right" valign="top">Comentarios:</td>
<td><textarea name="comentarios" cols="50" rows="5"></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Usuario:</td>
<td><input type="text" name="Usuario" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insertar registro"></td>
</tr>
</table>
<p>
<input type="hidden" name="id_comentarios" value="">
<input type="hidden" name="fecha" value="">
<input type="hidden" name="MM_insert" value="form1">
</p>
<p>&nbsp; </p>

<table border="0" align="center">
<tr>
<td>comentarios</td>
<td>Usuario</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_comentarios['comentarios']; ?></td>
<td><?php echo $row_comentarios['Usuario']; ?></td>
</tr>
<?php } while ($row_comentarios = mysql_fetch_assoc($comentarios)); ?>
</table>
<div align="center"></div>
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($comentarios);
?>