Foros del Web » Programando para Internet » PHP »

Ayuda con Dreamwaver CS3 y mostrar tabla

Estas en el tema de Ayuda con Dreamwaver CS3 y mostrar tabla en el foro de PHP en Foros del Web. y bien miren estoy haciendo algunas pruebas con el fin de aprender como: hacer un formulario, hacer una consulta, borrar registro, actualizar un registro. Instale ...
  #1 (permalink)  
Antiguo 29/07/2008, 13:29
Avatar de riechst  
Fecha de Ingreso: julio-2008
Mensajes: 6
Antigüedad: 15 años, 8 meses
Puntos: 0
Ayuda con Dreamwaver CS3 y mostrar tabla

y bien miren estoy haciendo algunas pruebas con el fin de aprender como: hacer un formulario, hacer una consulta, borrar registro, actualizar un registro. Instale phpmyadmin, he creado ya mi base de datos, algunas tablas, algunas relaciones y con el fin de darle una mejor vista decidi instalar dreamweaver CS3, ya tengo la conexion con mysql, de echo ya tengo el formulario, la consulta por ID, actualizar registro, y borrar registro, pero viene a mi mente que seria muy util desplegar en la pagina todo el contenido de una tabla, es ahi donde esta mi duda, segun lei por la red solo hay que insertar una tabla dinamica y seleccionar el record set, pero al revizar ya en el navegador solo aparece el primer registro y me manda un warning :

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\prueba\lista.php on line 17


El recordset, donde va la consulta sql queda asi : SELECT *
FROM paciente , para seleccionar toda la tabla paciente

y el codigo de toda la pagina seria este:
************************************************** ************

<table border="1" cellpadding="2" cellspacing="2">
<tr>
<td>ID</td>
<td>nombre</td>
<td>telefono</td>
<td>ciudad</td>
<td>postal</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['ID']; ?></td>
<td><?php echo $row_Recordset1['nombre']; ?></td>
<td><?php echo $row_Recordset1['telefono']; ?></td>
<td><?php echo $row_Recordset1['ciudad']; ?></td>
<td><?php echo $row_Recordset1['postal']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<?php require_once('Connections/lol.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;
}
}

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_lol, $lol);
$query_Recordset1 = "SELECT * FROM paciente";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $lol) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

mysql_free_result($Recordset1);
?>
************************************************** ******************
  #2 (permalink)  
Antiguo 29/07/2008, 13:49
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Ayuda con Dreamwaver CS3 y mostrar tabla

Hola,
Prueba con:
Código PHP:
<?php require_once('Connections/lol.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;
}
}

$maxRows_Recordset1 10;
$pageNum_Recordset1 0;
if (isset(
$_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 $pageNum_Recordset1 $maxRows_Recordset1;

mysql_select_db($database_lol$lol);
$query_Recordset1 "SELECT * FROM paciente";
$query_limit_Recordset1 sprintf("%s LIMIT %d, %d"$query_Recordset1$startRow_Recordset1$maxRows_Recordset1);
$Recordset1 mysql_query($query_limit_Recordset1$lol) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);

if (isset(
$_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 mysql_query($query_Recordset1);
$totalRows_Recordset1 mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

mysql_free_result($Recordset1);
?>
<table border="1" cellpadding="2" cellspacing="2">
<tr>
<td>ID</td>
<td>nombre</td>
<td>telefono</td>
<td>ciudad</td>
<td>postal</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['ID']; ?></td>
<td><?php echo $row_Recordset1['nombre']; ?></td>
<td><?php echo $row_Recordset1['telefono']; ?></td>
<td><?php echo $row_Recordset1['ciudad']; ?></td>
<td><?php echo $row_Recordset1['postal']; ?></td>
</tr>
<?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
</table>
La tabla estaba antes que la conexion a la bd.
Suerte
Salu2
__________________
Half Music - www.halfmusic.com
  #3 (permalink)  
Antiguo 29/07/2008, 14:31
Avatar de riechst  
Fecha de Ingreso: julio-2008
Mensajes: 6
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Ayuda con Dreamwaver CS3 y mostrar tabla

HOLA PUES, HE COPIADO Y PEGADO EL CODIGO QUE POSTEASTE, MMM CON UN MISMO RESULTADO EL MISMO WARNING, Y EL MISMO RESULTADO, SOLO EL PRIMER REGISTRO DE LA TABLA, IMAGINO QUE EN EL DO WHILE LA FUNCION mysql_fetch_assoc NO HACE SU TRABAJO, PUEDO SUSTITUIRLA POR OTRA???
OQUE SERA LO QUE PASA?
  #4 (permalink)  
Antiguo 29/07/2008, 14:40
Avatar de Taldreakan  
Fecha de Ingreso: julio-2008
Mensajes: 128
Antigüedad: 15 años, 8 meses
Puntos: 2
Respuesta: Ayuda con Dreamwaver CS3 y mostrar tabla

Coloca el free_result despues del while
Código PHP:
...
<?
    
} while ($row_Recordset1 mysql_fetch_assoc($Recordset1));
?> 
</table>
<?
  mysql_free_result
($Recordset1);
?>
Haber que pasa.
  #5 (permalink)  
Antiguo 29/07/2008, 14:51
Avatar de riechst  
Fecha de Ingreso: julio-2008
Mensajes: 6
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Ayuda con Dreamwaver CS3 y mostrar tabla

awesome, la respuesta estaba en el mysql_free_result($Recordset1);
lo movi de donde staba y aparecio mi tabla, je je, pero se desplego como texto en la pagina, asique lo borre, y aun funciona, jajaja
bueno gracias a todos, genial, pero podrian decirme que hace este metodo mysql_free_result ()
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:10.