tengo un problema con una consulta que estoy haciendo en dreamweaver para saber que personas no han pagado un servicio que se debe pagar mensual.
se me ocurrió la siguiente idea
cree una tabla pagos donde se guardan mes, año, idcliente y otros datos mediante un formulario envio el mes y el año a otra pagina y ahi obtengo el idcliente de todos los que han pagado ese mes, hasta el momento todo va bien y me arroja los resultados muy bien.
ahora tengo otra tabla que se llama clientes donde estan todos los datos personales del cliente incluyendo el idcliente por consiguiente hago un consulta a esa tabla clientes por idcliente dandole todos los valores idcliente que me dio la consulta a la tabla pagos pero solicitandole que busque los valores diferentes y los imprima por pantalla.
el problema de del asunto es que la consulta solo se hace una vez y no se repite el mismo numero veces que me dio como resultado en la tabla dinamica.
si alguien me puede ayudar se lo agradeceria mucho.
aqui les dejo el codigo:
Código PHP:
[QUOTE][QUOTE][HIGHLIGHT="PHP"]<?php require_once('Connections/login.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "error.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?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;
}
}
$colname_pagos = "-1";
if (isset($_POST['mes'])) {
$colname_pagos = $_POST['mes'];
}
$colname2_pagos = "-1";
if (isset($_POST['year'])) {
$colname2_pagos = $_POST['year'];
}
mysql_select_db($database_login, $login);
$query_pagos = sprintf("SELECT * FROM pagos WHERE mes = %s AND year=%s", GetSQLValueString($colname_pagos, "text"),GetSQLValueString($colname2_pagos, "double"));
$pagos = mysql_query($query_pagos, $login) or die(mysql_error());
$row_pagos = mysql_fetch_assoc($pagos);
$totalRows_pagos = mysql_num_rows($pagos);
$colname_nopagan = "-1";
if (isset($row_pagos['idcliente'])) {
$colname_nopagan = $row_pagos['idcliente'];
}
mysql_select_db($database_login, $login);
$query_nopagan = sprintf("SELECT * FROM clientes WHERE idcliente <> %s", GetSQLValueString($colname_nopagan, "int"));
$nopagan = mysql_query($query_nopagan, $login) or die(mysql_error());
$row_nopagan = mysql_fetch_assoc($nopagan);
$totalRows_nopagan = mysql_num_rows($nopagan);
?>
Código HTML:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>Documento sin título</title> <link href="estilos.css" rel="stylesheet" type="text/css"> </head> <body> <table border="1"> <tr> <td>idpago</td> <td>idcliente</td> <td>documento</td> <td>mes</td> <td>year</td> <td>valor</td> <td>fecha_pago</td> <td>afiliacionnueva</td> <td>efectivo</td> <td>datafono</td> <td>consignacion</td> <td>ingresado_por</td> <td>observaciones</td> </tr> <?php do { ?> <tr> <td><?php echo $row_pagos['idpago']; ?></td> <td><?php echo $row_pagos['idcliente']; ?></td> <td><?php echo $row_pagos['documento']; ?></td> <td><?php echo $row_pagos['mes']; ?></td> <td><?php echo $row_pagos['year']; ?></td> <td><?php echo $row_pagos['valor']; ?></td> <td><?php echo $row_pagos['fecha_pago']; ?></td> <td><?php echo $row_pagos['afiliacionnueva']; ?></td> <td><?php echo $row_pagos['efectivo']; ?></td> <td><?php echo $row_pagos['datafono']; ?></td> <td><?php echo $row_pagos['consignacion']; ?></td> <td><?php echo $row_pagos['ingresado_por']; ?></td> <td><?php echo $row_pagos['observaciones']; ?></td> </tr> <?php } while ($row_pagos = mysql_fetch_assoc($pagos)); ?> </table> <p> </p> <p> </p> <p> </p> <table border="1"> <tr> <td>idcliente</td> <td>documento</td> <td>apellido1</td> <td>apellido2</td> <td>nombres</td> <td>fecha_ingreso</td> <td>fecha_retiro</td> <td>activo</td> <td>salario</td> <td>fijo</td> <td>celular</td> <td>direccion</td> <td>eps</td> <td>nombre_eps</td> <td>pension</td> <td>nombre_fondo</td> <td>arl</td> <td>riesgo</td> <td>taxista</td> <td>arl_ind</td> <td>caja</td> <td>afiliado_emp</td> <td>empresa</td> <td>correo</td> <td>observaciones2</td> </tr> <?php do { ?> <tr> <td><?php echo $row_nopagan['idcliente']; ?></td> <td><?php echo $row_nopagan['documento']; ?></td> <td><?php echo $row_nopagan['apellido1']; ?></td> <td><?php echo $row_nopagan['apellido2']; ?></td> <td><?php echo $row_nopagan['nombres']; ?></td> <td><?php echo $row_nopagan['fecha_ingreso']; ?></td> <td><?php echo $row_nopagan['fecha_retiro']; ?></td> <td><?php echo $row_nopagan['activo']; ?></td> <td><?php echo $row_nopagan['salario']; ?></td> <td><?php echo $row_nopagan['fijo']; ?></td> <td><?php echo $row_nopagan['celular']; ?></td> <td><?php echo $row_nopagan['direccion']; ?></td> <td><?php echo $row_nopagan['eps']; ?></td> <td><?php echo $row_nopagan['nombre_eps']; ?></td> <td><?php echo $row_nopagan['pension']; ?></td> <td><?php echo $row_nopagan['nombre_fondo']; ?></td> <td><?php echo $row_nopagan['arl']; ?></td> <td><?php echo $row_nopagan['riesgo']; ?></td> <td><?php echo $row_nopagan['taxista']; ?></td> <td><?php echo $row_nopagan['arl_ind']; ?></td> <td><?php echo $row_nopagan['caja']; ?></td> <td><?php echo $row_nopagan['afiliado_emp']; ?></td> <td><?php echo $row_nopagan['empresa']; ?></td> <td><?php echo $row_nopagan['correo']; ?></td> <td><?php echo $row_nopagan['observaciones2']; ?></td> </tr> <?php } while ($row_nopagan = mysql_fetch_assoc($nopagan)); ?> </table>