Links, Variables - Newb question

SpaceshipSpaceship
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch

elixium

New Member
Impact
0
Links, Variables?

Hi everyone,


I have many links to many html files but the html files are all the same except for one variable.

How can I make the links link to one piece of code (html) and insert the variable into the appropriate place in that code instead of the above situation?



Thanks
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Do you have link such as
"index_page1.html"
"index_page2.html"
"index_page3.html", etc and you want the quickest way to write the link?
 
0
Close
Ok I will explain myself fully....

I have 100s of files with the following code in:

<object codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab" height="396" width="704" classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616"><param name="autoplay" value="false"><param name="src" value="http://video.stage6.com/000000/.divx" /><param name="custommode" value="Stage6" /><param name="showpostplaybackad" value="false" /><embed type="video/divx" src="http://video.stage6.com/000000/.divx" pluginspage="http://go.divx.com/plugin/download/" showpostplaybackad="false" custommode="Stage6" autoplay="false" height="376" width="704" /></object>

I want to have one copy of that code, not 100s
I want the link to insert the desired variable in this section of the code here:
<param name="src" value="http://video.stage6.com/000000/.divx" />
The variable is the "0000000" bit.

Rather than link to a html file with a copy of that code and variable in./ link to a duplicate of the code with changed variable.

I have found a way to move all the duplicates of the code into one html file with an ajax pagination script
however, now I need a way around this code duplication.

Its not really a newb question, just that I am new to this :].
 
Last edited:
0
Close
Is this variables from the database, or just a manually added into all the pages? If it is to the database you would want to have a mysql select with the fetch array and have the code in a while loop with the variable you want replaced by the array for the right field in the database.

If not you could have a get in the URL so that you could go to like:

yoursite.com/yourpage.php?video=VALUEHERE

and then the php script would grab it and display the appropriate video:

PHP:
<?php
$video = $_GET['video']; 
?>
<object codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab" height="396" width="704" classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616"><param
name="autoplay" value="false"><param name="src"
value="http://video.stage6.com/000000/.divx" />
<param name="custommode" value="Stage6" /><param
name="showpostplaybackad" value="false" />
<embed type="video/divx" src="<?php echo $video ?>" pluginspage="http://go.divx.com/plugin/download/"
showpostplaybackad="false" custommode="Stage6" autoplay="false" 
height="376" width="704" /></object>

If you dont want your site's url to have the ?video= or want to make it more search engine friendly you could use mod_rewrite in the .htaccess like below:

yourpage-video-(Your Value).htm

PHP:
Options +FollowSymLinks
RewriteEngine on
RewriteRule yourpage-video-(.*).htm$ yourpage.php?video=$1&


yourpage/video/(Any Value)/


PHP:
Options +FollowSymLinks
RewriteEngine on
RewriteRule yourpage/video/(.*)/ yourpage.php?video=$1&
 
Last edited:
0
Close
Thanks a lot, the variables are not from a database, the php solution you posted should work, this can be also be done in ASP or..? I've never done serverside code except includes before.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back