Re: Newbie - Is this possible with mysql? can i fake it in php?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Help-

When I run the following code instead of getting the correct result,
"Resourse id #5" is displayed. If I run the printed query from the mysql
console the output is correct.

What am I doing wrong?

Thanks in advance,
Max

        $sql = "select a.domain, a.transport from transport as a, acl as b
where a.id=b.transportId and b.adminId='$userid'";

        $result = mysql_query($sql,$db);

        while ($row = mysql_fetch_array($result)) {
                $domain = $row["domain"];
                $query = "select sum(a.recipient_size) from recipientstats
as a where a.recipient_email like '%$domain'";
                $size = mysql_query($query,$db) or die("query: " .
mysql_error());
                print "$query - $size";
                printf ("<td>%s</td><td>%s</td><td><a
href=\"stats.php?domain=%s\">view stats</a></td><td>%s</td>",
$row["domain"],
$row["transport"], $row["domain"], $size);
        }

        mysql_free_result($result);


"Max Clark" <max@clarksys.com> wrote in message
atb0h0$c49$1@main.gmane.org">news:atb0h0$c49$1@main.gmane.org...
> I've been reading various posts in the mysql mailing list that basically
say
> that this functionality (unions, subselects) does not exit within mysql
yet
> (I am just learning php/databases).
>
> Is there a way I can run this query in mysql? If not can I fake it out
with
> php? What would the best way to do that be?
>
> Thanks in advance,
> Max
>
> "Max Clark" <max@clarksys.com> wrote in message news:...
> > So I am trying to accomplish something like this:
> >
> > select a.domain, a.transport, sum(c.recipient_count)
sum(c.recipient_size)
> > from transport as a, acl as b, recipientstats as c where
> a.id=b.transportId
> > and b.adminId='1' and c.recipient_email like '%a.domain';
> >
> > But I know I am missing something because of the error.
> >
> > Can anyone point me in the right direction?
> >
> > Thanks in advance,
> > Max
> >
> > "Max Clark" <max@clarksys.com> wrote in message
> > news:ataq2r$ev1$1@main.gmane.org...
> > > Hi-
> > >
> > > I am trying to write a sql query that will output (domain, transport,
> > > sum(count), sum(size)) from multiple tables for many records.
> > >
> > > When the domain field is dynamic based on the adminId passed to the
> query,
> > > how do I execute the second query at the same time?
> > >
> > > Thanks in advance,
> > > Max
> > >
> > > select a.domain, a.transport from transport as a, acl as b where
> > > a.id=b.transportId and b.adminId='1';
> > > select sum(count), sum(size) from stats where email like '%a.domain';
> > >
> > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > Before posting, please check:
> > >    http://www.mysql.com/manual.php   (the manual)
> > >    http://lists.mysql.com/           (the list archive)
> > >
> > > To request this thread, e-mail <mysql-thread127356@lists.mysql.com>
> > > To unsubscribe, e-mail
> > <mysql-unsubscribe-gcdmg-mysql=m.gmane.org@lists.mysql.com>
> > > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> > >
> > >
> >
> >
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux