🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #3216

Re: contar campos en mysql

#3216
From: Jos� Miguel Santib��ez
Date: Thu, 14 Apr 2005 02:47
40 lines
1862 bytes
En el cap�tulo anterior (news:d3kkib$rb7$1@news1.nivel5.cl), "+mArkO+"
<kitim@porta.com> dijo: 

> <?php
> 
> $result = mysql_query("SELECT * FROM usuarios");
> if (!$result) {
>    echo 'Could not run query: ' . mysql_error();
>    exit;
> }
> /* retorna la cantidad total de campos de la consulta*/
> echo mysql_num_fields($result);
> ?>
> 

En ese caso, sugiero:
> $result = mysql_query("SELECT * FROM usuarios LIMIT 0,1");
Para ahorrar espacio... 

En todo caso, me parece m�s directo (la otra podr�a fallar si no hay 
registros)

<?php

  // conectar...

 $result = mysql_query("DESCRIBE usuarios");
 if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
 }
 /* retorna la cantidad total de campos de la consulta*/
 echo mysql_num_rows($result);
?>


-- 
                           Jose M. Santiba�ez A.
                             <jms@nivel5.cl>
                           <http://caos.cl/jms>
Technical Details
Message-ID: <Xns9637E7DE0F82Ejmsnews@200.27.221.71>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news.vcd.cl!not-for-mail
References: <d3kjl9$qv0$1@news1.nivel5.cl> <d3kkib$rb7$1@news1.nivel5.cl>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,446a760b4d2d3ec7
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII
Newsgroups: chile.comp.programacion
Subject: Re: contar campos en mysql
From: "Jos� Miguel Santib��ez" <jms@nospam.nivel5.cl>
References: <d3kjl9$qv0$1@news1.nivel5.cl> <d3kkib$rb7$1@news1.nivel5.cl>
Organization: Caos Consultores
Message-ID: <Xns9637E7DE0F82Ejmsnews@200.27.221.71>
User-Agent: Xnews/5.04.25
X-Face: +|NgjgFM{<rs%\Q|vUu16]a6,}?MJTA<!PEEI+x&Gw-Gyq+?$}fvo+.(,-r;)~Qzn)#{{nxU,OT?w^s<7m4ckCJ*L$c#I)yHL7b)GdU*#l
NNTP-Posting-Host: 32-47-89.adsl.terra.cl
Date: 13 Apr 2005 22:47:52 -0400
X-Trace: news.vcd.cl!not-for-mail 1113443272 32-47-89.adsl.terra.cl (13 Apr 2005 22:47:52 -0400)
Lines: 40
X-Authenticated-User: jms
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news.vcd.cl!not-for-mail