Re: output problem
| From: | 1LT John W. Holmes | Date: | Thu, 23 May 2002 17:12:24 +0000 |
| Subject: | Re: output problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98948@lists.php.net to get a copy of this message | ||
Don't do that, it's inefficient. You've got the right query, you just have
to assign the column an alias to use it the way you are.
SELECT COUNT(user) AS count_user FROM _request WHERE > date='$date' AND
status = 'open'
Then, after fetching the object from the result set, use
$line->count_user
The way you are doing it now works, too, but he column comes back named
'count(user)' and I'm sure you would get an error with $line->count(user),
so that's why you assign it an alias with AS.
Also note that you should be using mysql_select_db() and mysql_query()
instead of mysql_db_query()...
---John Holmes...
----- Original Message -----
From: <Sysadmin@saginawcontrol.com>
To: <cgrigor@mweb.com>; <php-db@lists.php.net>; <php-general@lists.php.net>
Sent: Thursday, May 23, 2002 9:57 AM
Subject: RE: [PHP] output problem
> You could try something like this....(did not test)
>
> <?
> echo date("Y-m-d");
> print $date;
> mysql_connect("servername","user","password")
> or die("Connect failed");
>
> $query = "select user from log_request where date='$date' and
> status = 'open'";
> $result = mysql_db_query("call_manage", "$query")
> or die("query_failed");
>
> $count=mysql_num_rows($result);
> $r=mysql_fetch_array($result);
> $user=$r["user"];
>
> print ("<table width=100% border=0><td><tr bgcolor=#f0f0f0>");
> print ("<br><b> </b>$count $user<br>\n");
> print ("</td></tr>");
>
>
> -----Original Message-----
> From: Chris Grigor [mailto:cgrigor@mweb.com]
> Sent: Thursday, May 23, 2002 9:48 AM
> To: php-db@lists.php.net; Php-General-List (E-mail)
> Subject: [PHP] output problem
>
>
> Howdi Alll
>
> some of you might laugh at this but I cant get this to work....
> Im doing a count on a field and want to diplay the result here is an
> example...
>
>
> <?php
> #error_reporting(E_ALL);
> echo date("Y-m-d");
> print $date;
> mysql_connect("servername", "user", "password")
> or die("Connect failed");
>
> $query = "select count(user) from log_request where
> date='$date' and status = 'open'";
> $result = mysql_db_query("call_manage", "$query")
> or die("query failed");
>
>
> while($line = mysql_fetch_object($result))
> {
> print ("<table width=100% border=0><td><tr bgcolor=#f0f0f0>");
> print ("<br><b> </b>$line->user<br>\n");
> print ("</td></tr>");
> }
> ?>
>
>
>
> what am I missing as it returns no value at all from $line->user,
> should I be
> doing this differently??
>
> Thankyou
>
> Chris
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
----------------------------------------------------------------------------
----
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php