For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2005 > next row in database









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author next row in database
liquidice

2005-02-07, 3:57 pm

If I had a list of records in a database, how would I be able to link a
'next button' that would pull out the next row of records from the database?
The sql statement on the PHP page queries the database for the picture type.

At the moment I have SELECT * FROM PicTable WHERE pictype=2

This pulls out all the records I want where the pictype = 2

But I cant seem to make the next button determine and pull out the next set
of records in the database and it's starting to get really irritating!


Geoff Berrow

2005-02-07, 3:57 pm

I noticed that Message-ID:
<42078821$0$16583$cc9e4d1f@news-text.dial.pipex.com> from liquidice
contained the following:

>But I cant seem to make the next button determine and pull out the next set
>of records in the database and it's starting to get really irritating!


If it's MySql it's dead easy. Just use LIMIT

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
liquidice

2005-02-07, 3:57 pm

I want to extract the next record from the database and display the picture
in a 'next' link on a php page. It's sort of a slideshow gallery which
dislpays the next image when the user clicks upon that next link

"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:9a6f01llchvndmpvlr47tvutag16ngjghs@
4ax.com...
>I noticed that Message-ID:
> <42078821$0$16583$cc9e4d1f@news-text.dial.pipex.com> from liquidice
> contained the following:
>
>
> If it's MySql it's dead easy. Just use LIMIT
>
> --
> Geoff Berrow (put thecat out to email)
> It's only Usenet, no one dies.
> My opinions, not the committee's, mine.
> Simple RFDs http://www.ckdog.co.uk/rfdmaker/



Geoff Berrow

2005-02-07, 3:57 pm

I noticed that Message-ID:
<42079c85$0$19154$cc9e4d1f@news-text.dial.pipex.com> from liquidice
contained the following:

>I want to extract the next record from the database and display the picture
>in a 'next' link on a php page. It's sort of a slideshow gallery which
>dislpays the next image when the user clicks upon that next link


Well you keep saying what you want but I don't see you try to do it.

OTTOMH and could contain errors...

<?php
if(isset($_GET['next'])){
$offset=$_GET['next']+1;
}
else{
$offset=0;
}

$sql="SELECT * FROM tblpics LIMIT $offset,1";
//run query
//display pics

echo "<a href=\"".$_SERVER['PHP_SELF']."?next=$offset>Next</a>";
?>




--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Geoff Berrow

2005-02-07, 3:57 pm

I noticed that Message-ID: <itcf01l7pqv92el4bs2518h4ioauk9nfod@4ax.com>
from Geoff Berrow contained the following:

>OTTOMH and could contain errors...

/Does/ contain errors...

Of course the $offset should increment /after/ the query.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
JDS

2005-02-08, 3:56 pm

On Mon, 07 Feb 2005 15:24:22 +0000, liquidice wrote:

> At the moment I have SELECT * FROM PicTable WHERE pictype=2
>
> This pulls out all the records I want where the pictype = 2
>
> But I cant seem to make the next button determine and pull out the next
> set of records in the database and it's starting to get really irritating!


Well what are you doing? I see no example attempt.

In any case, what you need is

1) the row id in a variable (not hard-coded)
2) a way to increment the row id

See Geoff B's answer for details.

--
JDS | jeffrey@go.away.com
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

liquidice

2005-02-08, 3:56 pm

You don't see an example attempt because I haven't posted a damn example
attempt yet!!
I appreciate your help, but just because I haven't posted any code doesn't
mean I've been sitting around twiddling my thumbs!

"JDS" <jeffrey@go.away.com> wrote in message
news:pan.2005.02.08.14.40.15.701492@go.away.com...
> On Mon, 07 Feb 2005 15:24:22 +0000, liquidice wrote:
>
>
> Well what are you doing? I see no example attempt.
>
> In any case, what you need is
>
> 1) the row id in a variable (not hard-coded)
> 2) a way to increment the row id
>
> See Geoff B's answer for details.
>
> --
> JDS | jeffrey@go.away.com
> | http://www.newtnotes.com
> DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
>



liquidice

2005-02-08, 3:56 pm

ok, maybe that was a little harsh, you're only trying to help and I do
apologise.

"JDS" <jeffrey@go.away.com> wrote in message
news:pan.2005.02.08.14.40.15.701492@go.away.com...
> On Mon, 07 Feb 2005 15:24:22 +0000, liquidice wrote:
>
>
> Well what are you doing? I see no example attempt.
>
> In any case, what you need is
>
> 1) the row id in a variable (not hard-coded)
> 2) a way to increment the row id
>
> See Geoff B's answer for details.
>
> --
> JDS | jeffrey@go.away.com
> | http://www.newtnotes.com
> DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
>



JDS

2005-02-08, 3:56 pm

On Tue, 08 Feb 2005 15:43:59 +0000, liquidice wrote:

> ok, maybe that was a little harsh, you're only trying to help and I do
> apologise.


Yes, maybe engaging brain before speaking would be a good idea. also, stop
top-posting. I realize you are doing it because you are using Outlook
Express, but that is no excuse.

--
JDS | jeffrey@go.away.com
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

liquidice

2005-02-09, 3:56 pm

Tell it to someone who cares, mate!

"JDS" <jeffrey@go.away.com> wrote in message
news:pan.2005.02.08.17.12.20.576355@go.away.com...
> On Tue, 08 Feb 2005 15:43:59 +0000, liquidice wrote:
>
>
> Yes, maybe engaging brain before speaking would be a good idea. also, stop
> top-posting. I realize you are doing it because you are using Outlook
> Express, but that is no excuse.
>
> --
> JDS | jeffrey@go.away.com
> | http://www.newtnotes.com
> DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
>



Terry

2005-02-09, 8:56 pm

liquidice wrote:[color=darkred]
> Tell it to someone who cares, mate!
>
> "JDS" <jeffrey@go.away.com> wrote in message
> news:pan.2005.02.08.17.12.20.576355@go.away.com...
>

Most of the people here (that are knowledgeable enough to help you) care
- have you heard of cutting off your nose to spite your face?
TK
who is not knowledgeable enough to help you in php - yet
Geoff Berrow

2005-02-10, 8:56 am

I noticed that Message-ID: <36vnegF55ved1U1@individual.net> from Terry
contained the following:

>Most of the people here (that are knowledgeable enough to help you) care
>- have you heard of cutting off your nose to spite your face?

Heh, I was thinking exactly the same thing.

>TK
>who is not knowledgeable enough to help you in php - yet

Maybe you've helped more than you think.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
liquidice

2005-02-10, 8:56 am


"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:1k4m01tu0tene4endlh0ci8lenq6bd7qmv@
4ax.com...
>I noticed that Message-ID: <36vnegF55ved1U1@individual.net> from Terry
> contained the following:
>
> Heh, I was thinking exactly the same thing.
>
> Maybe you've helped more than you think.
>
> --
> Geoff Berrow (put thecat out to email)
> It's only Usenet, no one dies.
> My opinions, not the committee's, mine.
> Simple RFDs http://www.ckdog.co.uk/rfdmaker/

[color=darkred]
Yup, I guess I was just in a funny mood yesterday, so this is a personal
apology to JDS (again), sorry JDS. I got the problem solved in the end,
thanks to you guys, especially Oli. Look, I'm not top posting any more
either :) and I even did a google search on proper etiquette on posting on
Usenet, hehe


Geoff Berrow

2005-02-10, 3:56 pm

I noticed that Message-ID:
<420b2cc4$0$16575$cc9e4d1f@news-text.dial.pipex.com> from liquidice
contained the following:

>I even did a google search on proper etiquette on posting on
>Usenet


Hmmm, did you miss the bit about only quoting sufficient to give
context? ;-)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
JDS

2005-02-10, 3:56 pm

On Thu, 10 Feb 2005 09:43:30 +0000, liquidice wrote:

> Yup, I guess I was just in a funny mood yesterday, so this is a personal
> apology to JDS (again), sorry JDS. I got the problem solved in the end,


No sweat, hoss. Been there.

--
JDS | jeffrey@go.away.com
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

liquidice

2005-02-16, 3:57 am

Tell it to someone who cares, mate!

"JDS" <jeffrey@go.away.com> wrote in message
news:pan.2005.02.08.17.12.20.576355@go.away.com...
> On Tue, 08 Feb 2005 15:43:59 +0000, liquidice wrote:
>
>
> Yes, maybe engaging brain before speaking would be a good idea. also, stop
> top-posting. I realize you are doing it because you are using Outlook
> Express, but that is no excuse.
>
> --
> JDS | jeffrey@go.away.com
> | http://www.newtnotes.com
> DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com