Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/02/2012, 13:33
chumy_
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: como ver todas las filas de una tabla con select que filtra

Este es el codigo de los select:

Código PHP:
<?php require_once('Connections/localhost.php'); ?>
<?php 
require_once('Connections/formulario.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;
}
}

mysql_select_db($database_localhost$localhost);
$query_proyectos "SELECT proy, noper FROM proyectos ORDER BY noper ASC";
$proyectos mysql_query($query_proyectos$localhost) or die(mysql_error());
$row_proyectos mysql_fetch_assoc($proyectos);
$totalRows_proyectos mysql_num_rows($proyectos);

mysql_select_db($database_formulario$formulario);
$query_estados "SELECT * FROM estado ORDER BY estado ASC";
$estados mysql_query($query_estados$formulario) or die(mysql_error());
$row_estados mysql_fetch_assoc($estados);
$totalRows_estados mysql_num_rows($estados);
?>
<!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>Documento sin título</title>
<style type="text/css">
#form1 {
    text-align: center;
}
</style>
</head>

<body>
<form id="form1" name="form1" method="get" action="proyecto_validado_elegido.php" target="down">
  <table width="650" border="0" align="center">
    <tr>
      <td width="644" align="center" valign="middle"><label for="noper"></label>
        <select name="noper" id="noper">
          <option value="">Seleccione un Proyecto...</option>
          <?php
do {  
?>
          <option value="<?php echo $row_proyectos['noper']?>"><?php echo $row_proyectos['proy']?></option>
          <?php
} while ($row_proyectos mysql_fetch_assoc($proyectos));
  
$rows mysql_num_rows($proyectos);
  if(
$rows 0) {
      
mysql_data_seek($proyectos0);
      
$row_proyectos mysql_fetch_assoc($proyectos);
  }
?>
      </select></td>
    </tr>
    <tr>
      <td align="center" valign="middle"><label for="estados"></label>
        <select name="estados" id="estados">
          <option value="">Seleccione un Estado...</option>
          <option value="">TODOS</option>
          <?php
do {  
?>
<option value="<?php echo $row_estados['estado']?>"><?php echo $row_estados['estado']?></option>
          <?php
} while ($row_estados mysql_fetch_assoc($estados));
  
$rows mysql_num_rows($estados);
  if(
$rows 0) {
      
mysql_data_seek($estados0);
      
$row_estados mysql_fetch_assoc($estados);
  }
?>
      </select></td>
    </tr>
  </table>
  <input type="submit" name="enviar" id="enviar" value="Seleccionar" />
</form>
</body>
</html>
<?php
mysql_free_result
($proyectos);

mysql_free_result($estados);
?>