![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
05/04/2010, 07:30
|
| | Fecha de Ingreso: marzo-2010
Mensajes: 2
Antigüedad: 14 años, 10 meses Puntos: 0 | |
Respuesta: consulta en varias tablas hola Megcapkill, gracias por responder
ya lo hice como me indicaste y la verdad sigo obteniendo lo mismo, para el primer registro si me manda el estado, municipio y la ciudad correcta, para los demas registros estos tres campos se repiten este es mi codigo.
<?php require_once('../Connections/db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_ase = 20;
$pageNum_ase = 0;
if (isset($_GET['pageNum_ase'])) {
$pageNum_ase = $_GET['pageNum_ase'];
}
$startRow_ase = $pageNum_ase * $maxRows_ase;
mysql_select_db($database_db, $db);
$query_ase = "SELECT * FROM asesores";
$query_limit_ase = sprintf("%s LIMIT %d, %d", $query_ase, $startRow_ase, $maxRows_ase);
$ase = mysql_query($query_limit_ase, $db) or die(mysql_error());
$row_ase = mysql_fetch_assoc($ase);
if (isset($_GET['totalRows_ase'])) {
$totalRows_ase = $_GET['totalRows_ase'];
} else {
$all_ase = mysql_query($query_ase);
$totalRows_ase = mysql_num_rows($all_ase);
}
$totalPages_ase = ceil($totalRows_ase/$maxRows_ase)-1; mysql_select_db($database_db, $db);
$query_edo = "SELECT asesores.select1, select_1.opcion FROM asesores, select_1 WHERE asesores.select1=select_1.id";
$edo = mysql_query($query_edo, $db) or die(mysql_error());
$row_edo = mysql_fetch_assoc($edo);
$totalRows_edo = mysql_num_rows($edo); mysql_select_db($database_db, $db);
$query_mun = "SELECT asesores.select2, select_2.opcion FROM asesores, select_2 WHERE asesores.select2=select_2.id";
$mun = mysql_query($query_mun, $db) or die(mysql_error());
$row_mun = mysql_fetch_assoc($mun);
$totalRows_mun = mysql_num_rows($mun); mysql_select_db($database_db, $db);
$query_city = "SELECT asesores.select3, SELECT_3.opcion FROM asesores, select_3 WHERE asesores.select3=select_3.id";
$city = mysql_query($query_city, $db) or die(mysql_error());
$row_city = mysql_fetch_assoc($city);
$totalRows_city = mysql_num_rows($city);
$queryString_ase = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_ase") == false &&
stristr($param, "totalRows_ase") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_ase = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_ase = sprintf("&totalRows_ase=%d%s", $totalRows_ase, $queryString_ase);
?>
<!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>Cecini Informenglish</title>
<style type="text/css">
<!--
@import url("../css/textoform.css");
@import url("../css/bluedream.css");
-->
</style>
</head>
<body>
<table width="982" border="0">
<tr bgcolor="#CCFFFF">
<td width="17"><a href="alta_ase.php"><img src="http://www.forosdelweb.com/f18/image/add.png" width="16" height="16" border="0" title="Agregar nuevo registro" /></a></td>
<td width="88" class="texto">CLAVE</td>
<td width="99" class="texto">NOMBRE</td>
<td width="109" class="texto">AP. PATERNO</td>
<td width="112" class="texto">AP. MATERNO</td>
<td width="67" class="texto">ESTADO</td>
<td width="129" class="texto">MUNICIPIO</td>
<td width="108" class="texto">CIUDAD</td>
<td width="86" class="texto">TELEFONO</td>
<td width="77" class="texto">STATUS</td>
<td colspan="2"> </td>
</tr>
<?php do { ?>
<tr>
<td> </td>
<td><?php echo $row_ase['cve_ase']; ?></td>
<td><?php echo $row_ase['non_ase']; ?></td>
<td><?php echo $row_ase['ap_pat_ase']; ?></td>
<td><?php echo $row_ase['ap_mat_ase']; ?></td>
<td><?php echo $row_edo['opcion']; ?></td>
<td><?php echo $row_mun['opcion']; ?></td>
<td><?php echo $row_city['opcion']; ?></td>
<td><?php echo $row_ase['tel']; ?></td>
<td><?php echo $row_ase['status']; ?></td>
<td width="21"><img src="http://www.forosdelweb.com/f18/image/database_edit.png" width="16" height="16" title="Modificar"/></td>
<td width="19"><img src="http://www.forosdelweb.com/f18/image/delete.png" width="16" height="16" title="Eliminar"/></td>
</tr>
<?php } while ($row_ase = mysql_fetch_assoc($ase)); ?>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($ase);
mysql_free_result($edo);
mysql_free_result($mun);
mysql_free_result($city);
?>
este es el codigo que uso para mostrar mis registros, y pues es esactamente donde hago la consulta para los estados, municipios y ciudades que no me sale, te decia que para el perimero si funciona pero para los demas se repite.
Última edición por ghost2629; 05/04/2010 a las 08:23 |