Copy link to clipboard
Copied
Hello all,
To the point: Selecting an option on the first page passes the query string value, in this case, 11, to the next page.
The next page presents numerous bits of data, in this case short prargraphs. There are only three paragraphs shown per page, and a navigation system is in place to allow the user to go back and forth between these groups of paragraphs.
It all works seamlessly.
What I want to ADD is the ability to pass the original query string value along (11) each time the user goes forward or back using the navigation links.
The navigation system is PHP and reloads the same page with the appropriate data.
I just want to pass a value along...how?
Thanks in advance!
Sincerely,
wordman
Anytime, man.
Copy link to clipboard
Copied
Seems to me the easiest way is to set a $_COOKIE with this value at the beginning.
Copy link to clipboard
Copied
Michael,
Many thanks for that. I have researched this extensively and (with my relative newcomer's knowledge and skill level) it is looking as though using cookies and sessions is my only hope.
I wanted to put out a general question: Do professional developers even think twice before using sessions and cookies nowadays? I remember years ago when a lot of people disabled cookies in their browsers, and today it seems as though that limits one's navigation of the net something fierce.
I wasn't sure if I should go the session/cookie route, if my users didnt have theirs switched on, they would not be able to access my galleries.
Please, I'd love to hear everyone's thoughts on this matter.
Sincerely,
wordman
Copy link to clipboard
Copied
It's pretty safe to use cookies, nowadays. Most people have cookies enabled, and those who don't are probably very used to having problems on various sites.
He's right, you don't HAVE to use cookies in this case, but I was just thinking that it would be the simplest option in this particular circumstance.
Copy link to clipboard
Copied
Michael,
I'm currently investigating an open-source script that does pagination for you. It has to do with PEAR, anyone have any ideas, pros/cons for this type of thing?
My apologies for sounding like such a dingbat...
Cheers,
wordman
Copy link to clipboard
Copied
You don't need to use a cookie if you don't want. Your script would simply need to read the query string value and then append it to the navigation links.
Copy link to clipboard
Copied
Bregent,
Thanks for the quick reply. I just posted a detailed description of what is going on for me. Passing the query string from one page to another isn't a problem, but passing it when scrolling through subsets of records that are updated on the same page IS.
Cheers,
wordman
Copy link to clipboard
Copied
>but passing it when scrolling through subsets of
>records that are updated on the same page IS.
Sorry, I still don't understand why that would be a problem. Any value that is available within a script, is available to be appended to a querystring. Please explain why this won't work.
Copy link to clipboard
Copied
Bregent,
I say this tongue-in-cheek, but if I knew why it didn't work, I'd fix it.
I have tried and tried, but it doesn't work. Take a look at my other post about subsets of records, the code is in there. Hit the Back or Next link and the next subset is loaded in the same page, but the query string, however amended, won't pass the numbers in either direction. It's been making me crazy for weeks now.
Again, please have a look at the code in the other post, specifically the navigation code.
And as always, I truly appreciate your help!
Sincerely,
wordman
Copy link to clipboard
Copied
Well, I don't do PHP but I looked at the code and I don't see you appending the original querystring value (11) to the prev/next links. All I see if the current page value.
echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'">
If you want to pass more than one value in a querystring then you need to seperate them with an ampersand or semicolon.
Copy link to clipboard
Copied
Or, for that matter, why DW's built-in pagination features can't handle it?
Copy link to clipboard
Copied
Bregent and Michael,
I tried amending those strings many, many times today and frustratingly, no dice. It have me quite a headache, literally.
As for DW's pagination you mention, I do all my coding in DW CS4 by hand. I really don't use much of its inbuilt features as I was once lectured that learning to hand code was a good thing to learn.
At any rate, from the existing code, I CAN make the data scroll back and forth between subsets, it's just that I lose the ability to display more information given by other queries (full description in that post, no need to repeat it here).
I thought for sure that I could amend those links, but it never passed them. Yee ha, eh?
Many thanks for your kind and thoughtful suggestions. I appreciate your presence here!
Sincerely,
wordman
Copy link to clipboard
Copied
>I thought for sure that I could amend those
>links, but it never passed them. Yee ha, eh?
Then your syntax was wrong. Can you provide some sample code you tried?
>it's just that I lose the ability to display
>more information given by other queries
This gets back to the problems you encounter when you rely on multiple queries. What is the reason this specific data can't be pulled with the main query?
Copy link to clipboard
Copied
Bregent,
Give my other post a read.
My galleries will increase in number over time, and I want to display them in TOC pages. I query the DB asking for records that match a specific category, and the query pulls them up. Then, I want them displayed in groups, eventually 20 or so at a time with the ability to navigate through the subsets. EXACTLY the same as any main forum page.
I have adapted Dav id Powers' code from PHP Solutions to do this, but for whatever reason, I can not make specific queries, just general SELECT *
So, if you read the other post, you'll see that I can use the first group of code to extract everything I want, but sans navigation, or I can use nav, but with diminished records displayed.
All of the info is in the other post.
As for syntax, I didn't keep the files, so all I can tell you was that I joined the query strings together with an ampersand. Feel free to send me an amended version of the code, I could use a fresh perspective.
Many thanks!
Sincerely,
wordman
Copy link to clipboard
Copied
I would take a look at DW's built-in pagination. Seriously. It's so simple. You can do it that way, then go back and study the code it used to learn it. I'm not sure why you're against that.
I have a simple table that uses pagination (via DW) here: http://www.melsbgc.com/test2.php
If I needed to add another page value to the URL, I would assign the value to a variable:
<?php $myvalue = $row_rs_query['value'];?> or <?php $myvalue = $_GET['value'];?> or <?php $myvalue = $_POST['value'];?>
Then just add the extra variable to the link. I'm going to go back and re-read this whole thread to see if I missed something, but this is really all there is to it.
Copy link to clipboard
Copied
Ok, wordman... big question:
Where is this original variable (11) coming from? Is it entered in a form? Where did that "11" originate?
If it's from a form, what's the form field's name?
Copy link to clipboard
Copied
Michael,
I'm not against using DWs inbuilt functions, I'm just used to hand coding.
The 11 is a query string value from the previous page. I'll elaborate...
You're at the main page, you have three chouces:
View galleries of the model who owns the website
View galleries of the model's friends
View galleries of several models together
Pick one and you get to a category page:
Category 1 (query string valye is 11)
Category 2 (query string valye is 12)
Category 3 (query string valye is 13)
Pick Category 1, and the query string = 11. This opens the TOC page and the value (of 11 in this case) is used to help select records from the database only relevant to this category.
Lemme know if this helps...
Thanks!!!
Cheers,
wordman
Copy link to clipboard
Copied
Yeah, we almost got this thing... what I need to know is two things.
1: how is the "11" passed? Is it via URL parameter? (That what it sounds like). If so, what is it called? Can you provide the exact links that you're using for each of the three choices? I want to see the exact URL that clicking each link leads to.
Copy link to clipboard
Copied
Michael,
Like Bregent, you are a gem.
The 11, 12 or 13 value is passed with these query strings:
a href="toc_2_ng.php?ct=11"
a href="toc_2_ng.php?ct=12"
a href="toc_2_ng.php?ct=13"
When you get to the TOC page, this code plucks the query string value:
$_SERVER['QUERY_STRING'];
$spec = $_GET['ct'];
It is only used in the SELECT query, specifically, SELECT * FROM galleries WHERE g_spec = '$spec%'
Site is still local, I'm having too many issues to upload and test remote, however here are the links following the sequence I mentioned:
You're at the main page, you have three choices:
URL http://localhost/main.php
View galleries of the model who owns the website
View galleries of the model's friends
View galleries of several models together
Pick one and you get to a category page:
URL http://localhost/categories.php?c=1 (c=1 comes from a query string from main.php)
Category 1 (query string value is 11)
Category 2 (query string value is 12)
Category 3 (query string value is 13)
Pick Category 1, and the query string = 11. This opens the TOC page and the value (of 11 in this case) is used to help select records from the database only relevant to this category.
URL http://localhost/toc_2_ng.php (the query string value for this page is 11, 12 or 13 based on the selection made on previous page...echoing the query string variable, $spec, verifies this)
Now, click the 'Next' link...
URL http://localhost/toc_2_ng.php?curPage=1
From there, click the 'Back' link...
URL http://localhost/toc_2_ng.php?curPage=0
Please let me know if this helps...or hinders.
You guys are fantastic.
Sincerely,
wordman
Copy link to clipboard
Copied
I'm a little confused about one thing... where is the "c" coming from? I get the "ct" but not the "c".
Anyway, probably irrelevant.
All you need to do is add the ct = $spec variable to the end of your pagination links using the ampersand:
http://localhost/toc_2_ng.php?curPage=1&ct=<?php echo $spec;?>
That's it.
Copy link to clipboard
Copied
Michael,
HOW THE YOU-KNOW-WHAT DID I MISS THAT???
Aye, it works perfectly. Now, I must implement it to do my bidding.
You, like Bregent, Murray, David Powers and others, are a TRUE ASSET to this forum.
If you're ever in Las Vegas, beer's on me.
THANKS!
Cheers (and feeling really friggin' stupid),
wordman
ps - the c=1 was menched in the previous post. It's a query string from the page preceding the TOC.
Copy link to clipboard
Copied
Perfect!
No problem, man... I ask a TON of questions on here. Like most, I'm self-taught. I'm just glad that I can give back every once in a while.
Take care.
+mf
Copy link to clipboard
Copied
...crap...
It didn't work. I was seeing a number returned from another variable I was echo-ing.
Still, I'll remain undaunted and carry on...
Copy link to clipboard
Copied
Well, we should find out why it's not working. If $spec is defined on the page, then you should be able to append it to your URL without trouble.
So you added
&ct=<?php echo $spec ;?>
to your pagination links, and it did not work? What did it do? Did it add anything to your URL? Did it only add "ct=" and nothing more?
Copy link to clipboard
Copied
STOP THE PRESSES...I GOT IT!
Michael,
You were right, I just, as usual, didn't provide enough info.
These were my original navlinks:
echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'"> Back </a>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'"> Next </a>';
All I had to do was implement your suggestion properly into my code. The navlinks are contained inside php tags, so all I had to do was amend the links thus:
echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'&ct='.($spec).' "> Back </a>';
echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'&ct='.($spec).' "> Next </a>';
And voila, the code WORKS, it carries the original query string back and forth DELIGHTFULLY, which then helps to keep my title and header information in place during navigation. Here's the complete navcode:
<div id="header4">
<p>Displaying <?php echo $startRow+1;
if ($startRow+1 < $galTotal) {
echo ' to ';
if ($startRow+SHOWMAX < $galTotal) {
echo $startRow+SHOWMAX;
}
else {
echo $galTotal;
}
}
echo " of $galTotal";
if ($curPage > 0) {
echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'&ct='.($spec).' "> Back </a>';
}
if ($startRow+SHOWMAX < $galTotal) {
echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'&ct='.($spec).' "> Next </a>';
}
?> · <a href="categories.php?c=1">Categories</a> · <a href="main.php">Home</a></p></div>
I owe you big time. Not only you but Bregent as well. Your constant support and suggestions led me to figuring this out.
YOURE ALL AWESOME!!!
Most sincerely,
wordman