PHP Question
I'm trying to database-enable a large web site using PHP/MySQL. Its working out alright, but can't figure my way through one problem:
I'm trying to automate the "Next Page" links to automatically see if there is another page to an article, and if there is, provide a next page link, and if not, give a link back to the Main page. It is sort of working. I'm using a URL in this format:
http://www.mypage.com/test.php?id=1&p=2
So this finds records for article id 1, page 2. But, I don't want to have to say p=1 on all articles. If it is only a one page article, I'd like to be able to leave off the p=1. Do you guys know how to do this?
Right now I'm usaing something like this:
$numpages = mysql_num_rows($content);
if ($numpages > 1) {
printf("%s", mysql_result($content,$p-1,"content"));
$page = mysql_result($content,$p-1,"pagenum");
printf("\n\npage %d", $page);
}
else {
printf("%s", mysql_result($content,0,"content"));
printf(" Back to %s", mysql_result($result,0,"guide"));
}
But, as expected, on a multi-page article, I have to specify p=1 or I get an error. How can I have this pull page 1 without specifying p=1.
As an example, it is similar to anandtech.com . His article system pulls articles based on id #, but all pages after page 1, use the p= variable, while page 1 can be pulled wihtout it in the URL.
I know this is long-winded, but I'd appreciate any help.
David Risley
Owner/Operator
PC Media, Inc.
http://www.pcmedianet.com
Web Services / Development
drisley posted this at 18:04 — 1st October 2000.
They have: 6 posts
Joined: Feb 2000
nevermind....
after some study, I found a way to do it using the empty() function.
Note to moderators and admins: this forum is hard to navigate guys. You shouldn't have taken away the path navigation on top of the thread list.
David Risley
Owner/Operator
PC Media, Inc.
http://www.pcmedianet.com
Web Services / Development
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.