473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Passing an incremental variable into a URL

21
Hi guys

I have a subdomain with 79 individual episode pages, and I'd like to create a "Next >>" link that reads the number included in the top page name, then adds a value of one, sending the user to the next higher-numbered page within the acceptable range of 01 to 79. Page 79 would wrap back to page 01. This would allow the user to move incrementally while I continue to use a single, embedded navigation page for all episodes.

For example, each page is ep01.html, ep02.html through ep79.html. The embedded navigation page works by targeting "_top" in each link. If the user is on page ep27.html clicks "Next Episode >>" in the navigator they load ep28.html. However, if the user is on page 79, they load ep01.html because they are at the end of the page range.

Here's the full URL of page one:
http://series.airwolf.tv/episodes/ep01.html
and the pending embedded navigator page:
http://series.airwolf.tv/episodes/epguidefinder.html
Nov 16 '07 #1
6 1785
Atli
5,058 Expert 4TB
Hi Wolfman.

You can use the $_SERVER['PHP_SELF'] variable to find out the name of the current file, and use that to find out what the next file should be.

Something like:
Expand|Select|Wrap|Line Numbers
  1. # Get the current file name and index of the next file
  2. $currentName = basename($_SERVER['PHP_SELF'], ".html");
  3. $currentIndex = substr($currentName, -2);
  4. $nextIndex = $currentIndex + 1;
  5.  
  6. # Make sure the index is not higher than 79
  7. if($nextIndex > 79)
  8.   $nextIndex = 0;
  9.  
  10. # Prefix the number with a 0 if it is less than 10
  11. if($nextIndex < 10)
  12.   $nextIndex = "0". $nextIndex;
  13.  
  14. # Print the link
  15. echo "<a href=\"ep{$nextIndex}.html\">Next</a>";
  16.  
Nov 16 '07 #2
Wolfman
21
Thanks. I added target=\"_top\" into the href since the link must call the parent window, but other wise embedded it as-is:

[PHP] <?php
# Get the current file name and index of the next file
$currentName = basename($_SERVER['PHP_SELF'], ".html");
$currentIndex = substr($currentName, -2);
$nextIndex = $currentIndex + 1;

# Make sure the index is not higher than 79
if($nextIndex > 79)
$nextIndex = 0;

# Prefix the number with a 0 if it is less than 10
if($nextIndex < 10)
$nextIndex = "0". $nextIndex;

# Print the link
echo "<a href=\"ep{$nextIndex}.html\" target=\"_top\">Next Episode >></a>";
?>[/PHP]

However, each time the link is clicked, it returns to page 01 only. Check it out by selecting any of the first five episodes here:

http://series.airwolf.tv/episodes/

You'll see the resulting "next episode>>"link in the little navigator window on the left.

Wolfman
Dec 10 '07 #3
I gone through of your code, and i think the problem is in line
[PHP]
echo "<a href=\"ep{$nextIndex}.html\" target=\"_top\">Next Episode >></a>";
[/PHP]

if possible plz try like this
[PHP]
echo "<a href=\"ep.{$nextIndex}.html\" target=\"_top\">Next Episode >></a>";
[/PHP]
ok best of luck ..

Thanks. I added target=\"_top\" into the href since the link must call the parent window, but other wise embedded it as-is:

[PHP] <?php
# Get the current file name and index of the next file
$currentName = basename($_SERVER['PHP_SELF'], ".html");
$currentIndex = substr($currentName, -2);
$nextIndex = $currentIndex + 1;

# Make sure the index is not higher than 79
if($nextIndex > 79)
$nextIndex = 0;

# Prefix the number with a 0 if it is less than 10
if($nextIndex < 10)
$nextIndex = "0". $nextIndex;

# Print the link
echo "<a href=\"ep{$nextIndex}.html\" target=\"_top\">Next Episode >></a>";
?>[/PHP]

However, each time the link is clicked, it returns to page 01 only. Check it out by selecting any of the first five episodes here:

http://series.airwolf.tv/episodes/

You'll see the resulting "next episode>>"link in the little navigator window on the left.

Wolfman
Dec 10 '07 #4
Wolfman
21
Thank you robin1983. I changed the line, but regretfully the chage results in an extra period being placed in the page name, but it still defaults to #01 each time. Further thoughts?

Wolfman
Dec 10 '07 #5
Wolfman
21
I echoed each variable individually and came up with this:

$currentName = epguidefinder.php
$currentIndex = hp
$nextIndex = 01

Remember that this script is running on a single page that is loaded within each parent HTML page. The benefit of a working script is that it senses the page it is loaded into, so a single instance serves all.

The embedded page is always called epguidefinder.php, so right now the script is detecting the page it's placed on, not the one it's embedded within.
Therefore it's taking the "hp" from "php" and making that the currentIndex variable.
So nextIndex is hp+1, which results in ep01.html every time.

Problem is, I'm not sure how to resolve the code.
First, it must sense the "_top" window, not itself
Second, it must truncate the filename without the .html like it currently did with the .php extension.
Dec 10 '07 #6
Wolfman
21
Solved it!

I used HTTP_REFERER instead of PHP_SELF.

Thanks everyone for your help!

Wolfman
Dec 10 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
5
by: Bangalore | last post by:
Hi In reversing string usring recursive function, i found problems in using incremental postfix , and incremental prefix 1 void rev(char*); 2 void main() 3 { 4 char s="STRING"; 5 ...
1
by: jane | last post by:
HI, I had a question on incremental backup. We had an incremental backup every weekend. We did full backup every other week. That is one week incremental + full , the other week is...
1
by: Jimmy Chen | last post by:
Recently I've done a db2 backup and restore/recovery, but the process for recovering the database was different than what I thought to be. here is what I did: DB2 is set in online mode -...
3
by: apple | last post by:
UDB v8 fp 6a on AIX 5.1.0.0 Below is a manual incremental recover from compressed backup datasets. With external compress backup datasets, can it be coded to do an automatic incremental recover?...
0
by: Willem | last post by:
Based on MK's TSI_SOON (http://www.trigeminal.com/)I've created a nifty little procedure that - whenever you compact you db you get an incremental backup copy. Given that you have a table with...
3
by: Alex Shturm | last post by:
Hi, I am trying to activate incremental link using VC7 (.NET 2003) on a pretty big project (executable size is more than 100Mb, and it gets linked from several dozen of libraries and object...
5
by: Joel Matthew | last post by:
My boss was asking about incremental backups. I was scratching my head, thinking that the transaction log and a backup policy (script) for each record set (sorry about the archaic terminology)...
8
by: Bern McCarty | last post by:
We have a large mixed dll that I can never seem to get to link incrementally. Below is the console output. For simplicity I've eliminated some stuff that we normally do when we really link this...
0
by: nbardach | last post by:
Hope this finds everyone well. Happy New Year! I'm trying to build a Loop for a set of dropdown menus I'm inserting into a form. Basically, the client has to be able to select 1 to 20 donors...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.