Foros del Web » Programando para Internet » PHP »

Contador de datos en BD

Estas en el tema de Contador de datos en BD en el foro de PHP en Foros del Web. Saludos... tengo hecho una lista de inmuebles donde me deberia contar a medida q se van mostrando y decirme 01 inmueble 02 inmbue 03 inmu ...
  #1 (permalink)  
Antiguo 04/09/2008, 08:45
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Contador de datos en BD

Saludos... tengo hecho una lista de inmuebles donde me deberia contar a medida q se van mostrando y decirme

01 inmueble
02 inmbue
03 inmu

y asi va... ya lo hice en un lugar y me funcionó, ahora bien, lo aplique en otro lugar y no me cuenta.. siempre me muestra 01 01 01 para todos los articulos mostrados

aqui esta como debe funcionar

http://www.indexa.com.ve/albarracin/in_new.php

y aqui esta el que no me funciona

Código PHP:
<?php include('conect.php');

$sql2="select * from productossec order by zonas ASC";
$sql_exec2=mysql_query($sql2) or die ( "[ERROR] Query: $sql2, error: " .mysql_error() );
$row2=mysql_fetch_assoc($sql_exec2);
$totalmysql_num_rows($sql_exec2);


$num$num 1;
$nusprintf("%02d"$num);

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;  charset=iso-8859-1" />
<title> Grupo Albarracin, C.A.</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #EFF0D0;
}
.style1 {    font-family: "Trebuchet MS";
    font-size: 12px;
    color: #4A491C;
}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<link href="css/estilo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style4 {color: #FFFFFF}
-->
</style>
</head>

<body onload="MM_preloadImages('images/fotoindex1over.jpg','images/fotoindex2over.jpg')">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
    <td width="796"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td background="http://www.forosdelweb.com/images/backleft.jpg">&nbsp;</td>
        <td width="736"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','736','height','421','src','internalheader2?sc=1','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','internalheader2?sc=1' ); //end AC code
        </script>
                <noscript>
                  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="736" height="421">
                  <param name="movie" value="internalheader2.swf?sc=1" />
                  <param name="quality" value="high" />
                  <embed src="internalheader2.swf?sc=1" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="736" height="421"></embed>
                </object>
                </noscript></td>
          </tr>
          <tr>
            <td valign="top" bgcolor="#FFFFFF"><img src="http://www.forosdelweb.com/images/medio.jpg" width="736" height="39" /><br />
                <br /></td>
          </tr>
          <tr>
            <td valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%" height="65"><div align="left"><img name="nuevos_titu" src="http://www.forosdelweb.com/images/secundarios_titulo.jpg" width="190" height="38" border="0" id="nuevos_titu" alt="" /></div></td>
                    <td width="50%"><div align="right"><img name="inmuebles_titu" src="http://www.forosdelweb.com/images/inmuebles_titu.jpg" width="185" height="65" border="0" id="inmuebles_titu" alt="" /></div></td>
              </tr>
              <tr>
                <td colspan="2"><br />
                <table width="710" border="0" align="center" cellpadding="0" cellspacing="3">
                  <tr>
                    <td valign="top"><table width="94%" border="0" align="center" cellpadding="0" cellspacing="0.">
                        <tr>
                          <td width="50%" valign="top"><span class="textoprincipal"><a href="index.php">Home</a> - Listado Secundarios</span></td>
                          <td width="50%" valign="top"><form name="form" id="form">
                              <div align="right"><span class="textostitulos">Seleccione el tipo de inmueble
                                <select name="jumpMenu" class="textoprincipal" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
                                      <option value="">Seleccione</option>
                                      <option value="in_new.php">Nuevos</option>
                                      <option value="in_sec.php">Secundarios</option>
                                    </select>
                                </span><br />
                              </div>
                          </form></td>
                        </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td valign="top">&nbsp;</td>
                  </tr>
                  <tr>
                    <td valign="top"><?php if ($total!=0){ ?><table width="100%" border="0" cellspacing="2" cellpadding="0">
                        <?php do { ?><tr>
                        <td width="60" height="40" rowspan="2" align="center" valign="middle" bgcolor="#f3f2d6" class="textoNUMEROS"><span class="textoNUMEROS2"><?php echo ($nu); ?></span></td>
                        <td><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td><span class="titulofichaprod"><?php echo $row2['zonas']; ?></span></td>
                          </tr>
                           
                        </table></td>
                      </tr>
                      <tr>
                        <td><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td><span class="textostitulos"><?php echo $row2['titulo']; ?></span></td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td align="center" valign="middle">&nbsp;</td>
                        <td><div align="justify">
                          <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                              <td><span class="textoprincipal"><?php echo $row2['titulo']; ?></span></td>
                              </tr>
                          </table>
                        </div></td>
                      </tr>
                      <tr>
                        <td align="center" valign="middle">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr><?php } while ($row2mysql_fetch_assoc($sql_exec2)); ?>
                    </table></td>
                  </tr>
                </table>
                <?php ?></td>
              </tr>
            </table>

y este es el url
http://www.indexa.com.ve/albarracin/in_sec.php

alguien ve mi error?
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 04/09/2008, 09:13
Avatar de Avatar810  
Fecha de Ingreso: agosto-2007
Ubicación: Por rumbos Regios
Mensajes: 485
Antigüedad: 16 años, 8 meses
Puntos: 23
Respuesta: [S.O.S] Contador de datos en BD

Lo que sucede es que el contador lo tienes fuera del ciclo... mete $num= $num + 1; $nu= sprintf("%02d", $num); dentro del do while y veras que ya te funciona
__________________
Una demo siempre funcionará correctamente hasta que toque algo tu (hasta ahora) cliente.
Avatar810
  #3 (permalink)  
Antiguo 04/09/2008, 09:22
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Respuesta: Contador de datos en BD

peeeeeeeeeeeeeerfecto... gracias :)
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
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:02.