Foros del Web » Programando para Internet » PHP »

problema al buscar con select

Estas en el tema de problema al buscar con select en el foro de PHP en Foros del Web. Amigos, tengo un pequeño dramita... Tengo un select, el cual selecciona un proyecto, y luego con el boton "seleccionar" me envia a otra pagina con ...
  #1 (permalink)  
Antiguo 30/12/2011, 08:38
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
problema al buscar con select

Amigos, tengo un pequeño dramita...

Tengo un select, el cual selecciona un proyecto, y luego con el boton "seleccionar" me envia a otra pagina con el id del proyecto, el cual filtra la busqueda...

El problema es que se quedo pegado en un ID (13-01) en especifico y aunque borre el historial, cambie de navegador o reinicie el pc sigue pegado ahi...

este es el codigo del select:

Código PHP:
<?php require_once('Connections/localhost.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_seleccion "SELECT proy, noper FROM proyectos ORDER BY proy ASC";
$seleccion mysql_query($query_seleccion$localhost) or die(mysql_error());
$row_seleccion mysql_fetch_assoc($seleccion);
$totalRows_seleccion mysql_num_rows($seleccion);
?>
<!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>
</head>

<body>
<table border="0">
  <tr>
    <td align="center"><form id="form1" name="form1" method="post" action="proyecto_elegido.php?cod_proy=<?php echo $row_seleccion['noper']; ?>">
      <select name="seleccion" id="seleccion">
        <option value="">Seleccione un Proyecto...</option>
        <?php
do {  
?>
        <option value="<?php echo $row_seleccion['noper']?>"><?php echo $row_seleccion['proy']?></option>
        <?php
} while ($row_seleccion mysql_fetch_assoc($seleccion));
  
$rows mysql_num_rows($seleccion);
  if(
$rows 0) {
      
mysql_data_seek($seleccion0);
      
$row_seleccion mysql_fetch_assoc($seleccion);
  }
?>
      </select>
      <input type="submit" name="seleccionar" id="seleccionar" value="Seleccionar" />
    </form></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($seleccion);
?>
  #2 (permalink)  
Antiguo 30/12/2011, 08:38
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: problema al buscar con select

y este es el codigo de la pagina que hace la "busqueda"

Código PHP:
<?php require_once('Connections/localhost.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_seleccionados 15;
$pageNum_seleccionados 0;
if (isset(
$_GET['pageNum_seleccionados'])) {
  
$pageNum_seleccionados $_GET['pageNum_seleccionados'];
}
$startRow_seleccionados $pageNum_seleccionados $maxRows_seleccionados;

$colname_seleccionados "-1";
if (isset(
$_GET['cod_proy'])) {
  
$colname_seleccionados $_GET['cod_proy'];
}
mysql_select_db($database_localhost$localhost);
$query_seleccionados sprintf("SELECT ncert, Fecha, proyecto, cod_proy, poblacion, calle, n, tipo_recinto, n1 FROM cert WHERE cod_proy = %s"GetSQLValueString($colname_seleccionados"text"));
$query_limit_seleccionados sprintf("%s LIMIT %d, %d"$query_seleccionados$startRow_seleccionados$maxRows_seleccionados);
$seleccionados mysql_query($query_limit_seleccionados$localhost) or die(mysql_error());
$row_seleccionados mysql_fetch_assoc($seleccionados);

if (isset(
$_GET['totalRows_seleccionados'])) {
  
$totalRows_seleccionados $_GET['totalRows_seleccionados'];
} else {
  
$all_seleccionados mysql_query($query_seleccionados);
  
$totalRows_seleccionados mysql_num_rows($all_seleccionados);
}
$totalPages_seleccionados ceil($totalRows_seleccionados/$maxRows_seleccionados)-1;

$queryString_seleccionados "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_seleccionados") == false && 
        
stristr($param"totalRows_seleccionados") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_seleccionados "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_seleccionados sprintf("&totalRows_seleccionados=%d%s"$totalRows_seleccionados$queryString_seleccionados);
?>
<!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">
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
}
</style>
</head>

<body>
<table width="950" border="0">
  <tr valign="middle">
    <td width="57"><?php if ($pageNum_seleccionados 0) { // Show if not first page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPage0$queryString_seleccionados); ?>"><img src="imagenes/First.gif" alt="" /></a>
      <?php // Show if not first page ?></td>
    <td width="406"><?php if ($pageNum_seleccionados 0) { // Show if not first page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPagemax(0$pageNum_seleccionados 1), $queryString_seleccionados); ?>"><img src="imagenes/Previous.gif" alt="" /></a>
      <?php // Show if not first page ?></td>
    <td width="401" align="right"><?php if ($pageNum_seleccionados $totalPages_seleccionados) { // Show if not last page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPagemin($totalPages_seleccionados$pageNum_seleccionados 1), $queryString_seleccionados); ?>"><img src="imagenes/Next.gif" alt="" /></a>
      <?php // Show if not last page ?></td>
    <td width="68" align="right"><?php if ($pageNum_seleccionados $totalPages_seleccionados) { // Show if not last page ?>
      <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPage$totalPages_seleccionados$queryString_seleccionados); ?>"><img src="imagenes/Last.gif" alt="" /></a>
      <?php // Show if not last page ?></td>
  </tr>
</table>
<table width="950" border="0" align="center">
  <tr>
    <td align="center"><strong>N&deg;</strong></td>
    <td align="center"><strong>FECHA</strong></td>
    <td align="center"><strong>PROYECTO</strong></td>
    <td align="center"><strong>DIRECCION</strong></td>
    <td align="center"><p>MODIFICACI&Oacute;N</p></td>
    <td align="center">VALIDAR</td>
  </tr>
  <?php do { ?>
    <tr>
      <td align="center"><?php echo $row_seleccionados['ncert']; ?></td>
      <td align="center"><?php echo $row_seleccionados['Fecha']; ?></td>
      <td><?php echo $row_seleccionados['proyecto']; ?></td>
      <td><?php echo $row_seleccionados['poblacion']; ?> <?php echo $row_seleccionados['calle']; ?> <?php echo $row_seleccionados['n']; ?> <?php echo $row_seleccionados['tipo_recinto']; ?> <?php echo $row_seleccionados['n1']; ?></td>
      <td align="center"><form id="form1" name="form1" method="post" action="">
        <input type="submit" name="validacion" id="validacion" value="Modificar" />
      </form></td>
      <td align="center"><form id="form2" name="form2" method="post" action="">
        <input type="submit" name="validar" id="validar" value="Validar" />
      </form></td>
    </tr>
    <?php } while ($row_seleccionados mysql_fetch_assoc($seleccionados)); ?>
</table>
<table width="950" border="0">
  <tr valign="middle">
    <td width="57"><?php if ($pageNum_seleccionados 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPage0$queryString_seleccionados); ?>"><img src="imagenes/First.gif" /></a>
        <?php // Show if not first page ?></td>
    <td width="406"><?php if ($pageNum_seleccionados 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPagemax(0$pageNum_seleccionados 1), $queryString_seleccionados); ?>"><img src="imagenes/Previous.gif" /></a>
        <?php // Show if not first page ?></td>
    <td width="401" align="right"><?php if ($pageNum_seleccionados $totalPages_seleccionados) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPagemin($totalPages_seleccionados$pageNum_seleccionados 1), $queryString_seleccionados); ?>"><img src="imagenes/Next.gif" /></a>
        <?php // Show if not last page ?></td>
    <td width="68" align="right"><?php if ($pageNum_seleccionados $totalPages_seleccionados) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_seleccionados=%d%s"$currentPage$totalPages_seleccionados$queryString_seleccionados); ?>"><img src="imagenes/Last.gif" /></a>
        <?php // Show if not last page ?></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($seleccionados);
?>
donde esta el p*** error?
  #3 (permalink)  
Antiguo 02/01/2012, 07:42
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: problema al buscar con select

alguna pista?
  #4 (permalink)  
Antiguo 02/01/2012, 15:11
 
Fecha de Ingreso: agosto-2011
Ubicación: Viña del Mar, Chile
Mensajes: 311
Antigüedad: 12 años, 8 meses
Puntos: 50
Respuesta: problema al buscar con select

Hola Chumy...no miré en detalle el código por los efectos del año nuevo XD..pero en tu formulario envías los valores por POST y en la página que los procesa los recibes por GET por lo que nunca existirá una comprobación.., además por lo que veo usas dreamweaver para generar las consultas ...trata de ordenarlas y comentarlas porque DW genera código pero no lo ordena..si lo comentas es más fácil poder ayudar

Saludos,
__________________
He aprendido mucho y sigo aprendiendo cada día aquí...así que ayudo cuando puedo para disminuir mi deuda XD..
mi hobby

Etiquetas: html, mysql, select, sql
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 22:50.