Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] PHP OO no me muestra el primer registro

Estas en el tema de no me muestra el primer registro en el foro de PHP en Foros del Web. Buenas tengo mi tabla ingresar_registros que contiene 10 registros con los mismos datos. Lo que realiza mi código es buscar por SERIE y todos los ...
  #1 (permalink)  
Antiguo 24/10/2015, 10:25
 
Fecha de Ingreso: octubre-2015
Mensajes: 8
Antigüedad: 8 años, 6 meses
Puntos: 0
no me muestra el primer registro

Buenas tengo mi tabla ingresar_registros que contiene 10 registros con los mismos datos.

Lo que realiza mi código es buscar por SERIE y todos los registros de la columna SERIE que sean iguales a SERIE se muestren cosa que si lo hace.

Lo que pasa es que no me muestra el Registro 1 que también tiene la misma SERIE
al parecer tengo que igualar serie pero no se como realizarlo.


lo siguiente es que al no encontrar dicha serie me muestre "nose encontro ningun equipo con dicha serie".


Antemano Gracias



Código PHP:
<?php require_once('../Connections/conexion_servicio_tecnico.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;
}
}
$colname_Rs_buscar_registro "-1";
if (!empty(
$_GET['serie'])) {
  
$colname_Rs_buscar_registro $_GET['serie'];
}
mysql_select_db($database_conexion_servicio_tecnico$conexion_servicio_tecnico);
$query_Rs_buscar_registro sprintf("SELECT * FROM equipos_ingresados WHERE serie = %s"GetSQLValueString($colname_Rs_buscar_registro"text"));
$Rs_buscar_registro mysql_query($query_Rs_buscar_registro$conexion_servicio_tecnico) or die(mysql_error());
$row_Rs_buscar_registro mysql_fetch_assoc($Rs_buscar_registro);
$totalRows_Rs_buscar_registro mysql_num_rows($Rs_buscar_registro);
?>
<html>
<head>
<title>Documento sin título</title>
<script type="text/javascript">
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es necesaria.\n'; }
    } if (errors) alert('Para realizar la busqueda:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
</script>
</head>
<body>
<form name="form1" method="get" action="buscar_registro.php">
  <table width="200" border="1">
    <tr>
      <td>Buscar Serie</td>
      <td><input type="text" name="serie" id="serie"></td>
    </tr>
    <tr>
      <td colspan="2"><input name="bserie" type="submit" id="bserie" onClick="MM_validateForm('serie','','R');return document.MM_returnValue" value="Buscar"></td>
    </tr>
  </table>
</form>
<table border="1">
   <tr>
     <td>empresa</td>
     <td>contacto</td>
     <td>correo</td>
     <td>telefono</td>
     <td>equipo</td>
     <td>marca</td>
     <td>modelo</td>
     <td>serie</td>
     <td>servicio</td>
     <td>fecha</td>
     <td>observaciones</td>
     <td>solucion</td>
     <td>operacion</td>
   </tr>
<?php
while($row_Rs_buscar_registro mysql_fetch_assoc($Rs_buscar_registro)){
    echo 
'<tr>
            <td>'
.$row_Rs_buscar_registro['empresa'].'</td>
              <td>'
.$row_Rs_buscar_registro['contacto'].'</td>
              <td>'
.$row_Rs_buscar_registro['correo'].'</td>
              <td>'
.$row_Rs_buscar_registro['telefono'].'</td>
              <td>'
.$row_Rs_buscar_registro['equipo'].'</td>
              <td>'
.$row_Rs_buscar_registro['marca'].'</td>
              <td>'
.$row_Rs_buscar_registro['modelo'].'</td>
              <td>'
.$row_Rs_buscar_registro['serie'].'</td>
              <td>'
.$row_Rs_buscar_registro['servicio'].'</td>
              <td>'
.$row_Rs_buscar_registro['fecha'].'</td>
              <td>'
.$row_Rs_buscar_registro['observaciones'].'</td>
              <td>'
.$row_Rs_buscar_registro['solucion'].'</td>
              <td>'
.$row_Rs_buscar_registro['idingreso'].'</td>            
         </tr>'
;
}
?>
</table>
</body>
</html>
<?php
mysql_free_result
($Rs_buscar_registro);
?>
  #2 (permalink)  
Antiguo 24/10/2015, 10:37
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: no me muestra el primer registro

Cita:
Iniciado por AaronziitoO Ver Mensaje
Buenas tengo mi tabla ingresar_registros que contiene 10 registros con los mismos datos.

Lo que realiza mi código es buscar por SERIE y todos los registros de la columna SERIE que sean iguales a SERIE se muestren cosa que si lo hace.

Lo que pasa es que no me muestra el Registro 1 que también tiene la misma SERIE
al parecer tengo que igualar serie pero no se como realizarlo.


lo siguiente es que al no encontrar dicha serie me muestre "nose encontro ningun equipo con dicha serie".


Antemano Gracias
Saludo
A ver.

Como es eso que

Lo que realiza mi código es buscar por SERIE y todos los registros de la columna SERIE que sean iguales a SERIE se muestren cosa que si lo hace.

Lo que pasa es que no me muestra el Registro 1 que también tiene la misma SERIE
al parecer tengo que igualar serie pero no se como realizarlo.

Creo que te estás contradiciendo, dices que lo hace, pero luego que no!

Pregunto algo, sí imprimes el query y lo corres directamente en phpmyadmin
o herramientas similares, sigue sin traer el 'Registro 1' ?

En ese caso, yo revisaría el valor del campo serie para el 'Registro 1'.

En cuanto a que informe que no hay equipos con determinada serie,
solo es cuestión de revisar sí la consulta trae o no registros,
que podría ser implementado en un if antes del while preguntando
por mysql_num_rows.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #3 (permalink)  
Antiguo 24/10/2015, 10:40
 
Fecha de Ingreso: octubre-2015
Mensajes: 8
Antigüedad: 8 años, 6 meses
Puntos: 0
Respuesta: no me muestra el primer registro

Cita:
Iniciado por mortiprogramador Ver Mensaje
Saludo
A ver.

Como es eso que

Lo que realiza mi código es buscar por SERIE y todos los registros de la columna SERIE que sean iguales a SERIE se muestren cosa que si lo hace.

Lo que pasa es que no me muestra el Registro 1 que también tiene la misma SERIE
al parecer tengo que igualar serie pero no se como realizarlo.

Creo que te estás contradiciendo, dices que lo hace, pero luego que no!

Pregunto algo, sí imprimes el query y lo corres directamente en phpmyadmin
o herramientas similares, sigue sin traer el 'Registro 1' ?

En ese caso, yo revisaría el valor del campo serie para el 'Registro 1'.

En cuanto a que informe que no hay equipos con determinada serie,
solo es cuestión de revisar sí la consulta trae o no registros,
que podría ser implementado en un if antes del while preguntando
por mysql_num_rows.



jaja es algo confusa
pero lo solucione
quitando
$row_Rs_buscar_registro = mysql_fetch_assoc($Rs_buscar_registro)
que puse al inicio nome percate

ahora busco como al realizar una búsqueda fallida (serie que no hay en base de datos)
al no encontrar datos mostrar "no se encontro datos"
puse un Else despues del while pero no me funciona.
gracias
  #4 (permalink)  
Antiguo 24/10/2015, 10:52
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: no me muestra el primer registro

Saludo.
Ahh, eso ya es otro cantar.

En cuanto a lo propuesto, sería algo así:

Código PHP:
if(mysql_num_rows($result) == 0)
echo 
'No hay equipos con esa serie';
else
{
while()...

__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #5 (permalink)  
Antiguo 24/10/2015, 10:59
 
Fecha de Ingreso: octubre-2015
Mensajes: 8
Antigüedad: 8 años, 6 meses
Puntos: 0
Respuesta: no me muestra el primer registro

Gracias bro por lo tanto doy como solucionado el tema

Etiquetas: fecha, html, muestra, mysql, primer, registro, select, sql, tabla
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 03:17.