RE: [PHP]Only 1 Query Result...help.
| From: | Matthew Loff | Date: | Tue, 16 Oct 2001 20:45:20 +0000 |
| Subject: | RE: [PHP]Only 1 Query Result...help. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71259@lists.php.net to get a copy of this message | ||
extract(mysql_fetch_assoc(mysql_query("SELECT MAX(picid) AS max_id FROM
pics", $conn)));
Will give you $max_id. You can also split it up, if you prefer...
$query = "SELECT MAX(picid) AS max_id FROM pics";
$result = mysql_query($query,$conn);
extract(mysql_fetch_assoc($result));
-----Original Message-----
From: Chris Cocuzzo [mailto:cuzo@mediaone.net]
Sent: Tuesday, October 16, 2001 3:20 PM
To: Philip Olson
Cc: php-general@lists.php.net
Subject: Re: [PHP]Only 1 Query Result...help.
alright. that part is pretty much finished up. I've run into another
curiosity/problem in writing another part of the photo system. I want to
find the largest ID in the db so that I can make sure of when the person
clicking through is at the end of the album
here's my query:
$query = "SELECT MAX(picid) FROM pics";
$result = mysql_query($query,$conn);
I'm a little bit unsure of how to pull this data out though(i was
thinking
mysql_fetch_array again). My first thought was: $max_id =
extract(mysql_fetch_array($result)).
Can anyone help out?
-chris-
----- Original Message -----
From: "Philip Olson" <philip@cornado.com>
To: "Dave Watkinson" <d.watkinson@mightymatch.com>
Cc: "Chris Cocuzzo" <cuzo@mediaone.net>; <php-general@lists.php.net>
Sent: Tuesday, October 16, 2001 2:07 AM
Subject: RE: [PHP]Only 1 Query Result...help.
>
> On Tue, 16 Oct 2001, Dave Watkinson wrote:
> > i don't think it's wise to create an array and fill it with one
element
> >
> > i would use mysql_fetch_row($result)
> >
> > just my tuppence worth ;-)
>
> I don't see the difference, both are arrays with _row being
enumerated.
> Perhaps you meant mysql_result(). At any rate, Chris was under the
> impression that a while() loop was required to use these _fetch_
functions
> when that's not the case. Using these functions to fetch one row of
data
> is very appropriate, associative or otherwise.
>
> Regards,
> Philip Olson
>
>
> > -----Original Message-----
> > From: Philip Olson [mailto:philip@cornado.com]
> > Sent: 15 October 2001 17:54
> > To: Chris Cocuzzo
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP]Only 1 Query Result...help.
> >
> >
> >
> > > but without using a loop to display
> > > just one result
> >
> > If you want just one row :
> >
> > $row = mysql_fetch_array($result);
> >
> > print $row['col'];
> >
> > Regards,
> > Philip Olson
> >
> >
> >
> > On Mon, 15 Oct 2001, Chris Cocuzzo wrote:
> >
> > > maybe I'm an idiot, but I don't understand how that helps in not
using
> > a
> > > loop to display the results. Could you explain a little more?
> > >
> > > thanks
> > > chris
> > >
> > >
> > > ----- Original Message -----
> > > From: "_lallous" <elias_bachaalany@yahoo.com>
> > > To: <php-general@lists.php.net>
> > > Sent: Monday, October 15, 2001 3:30 AM
> > > Subject: Re: [PHP]Only 1 Query Result...help.
> > >
> > >
> > > > try to see the SELECT * FROM table LIMIT max, offset
> > > >
> > > > see the LIMIT syntax.
> > > >
> > > > "Chris Cocuzzo" <cuzo@mediaone.net> wrote in message
> > > > news:002b01c154f3$0a113310$ae687780@webs224...
> > > > hey-
> > > >
> > > > I'm trying to put together a photo album system with
next/previous
> > buttons
> > > > that displays one picture at a time, and obviously the user has
to
> > click
> > > > through the buttons to navigate the pictures. I'm using this
line
> > for the
> > > > query
> > > >
> > > > $picquery = "SELECT picid,path,width,height FROM pics WHERE id =
> > $id";
> > > >
> > > > normally to display results I'd use the mysql_fetch_array
function
> > and
> > > print
> > > > it out like: $picdata[src];
> > > >
> > > > what i was wondering if there's another function that I can use
> > that'll
> > > > stick the results into an array or some other organized data
> > structure so
> > > I
> > > > can display them, but without using a loop to display just one
> > result
> > > >
> > > > thanks
> > > > chris
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > > > For additional commands, e-mail: php-general-help@lists.php.net
> > > > To contact the list administrators, e-mail:
> > php-list-admin@lists.php.net
> > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > > For additional commands, e-mail: php-general-help@lists.php.net
> > > To contact the list administrators, e-mail:
> > php-list-admin@lists.php.net
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail:
php-list-admin@lists.php.net
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail:
php-list-admin@lists.php.net
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
php-list-admin@lists.php.net
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net