•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 426,526 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,831 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 5480 | Replies: 8
![]() |
| |
•
•
Join Date: Nov 2004
Location: Milwaukee, WI
Posts: 62
Reputation:
Rep Power: 4
Solved Threads: 0
Morning everyone --
Can anyone help me with what is probably very simple?
I have a page where I want to get a variable from the URL and display it... so if my url is http://www.mysite.com/page.html?variable=hi
I want to get that "hi" out of there and print it out to the page.
Thanks in advance!
Can anyone help me with what is probably very simple?
I have a page where I want to get a variable from the URL and display it... so if my url is http://www.mysite.com/page.html?variable=hi
I want to get that "hi" out of there and print it out to the page.
Thanks in advance!
Web Design in Wisconsin : Milwaukee Web Design : Second Platform
•
•
Join Date: Nov 2004
Location: Milwaukee, WI
Posts: 62
Reputation:
Rep Power: 4
Solved Threads: 0
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation:
Rep Power: 5
Solved Threads: 48
It depends. It can be done in Javascript or using a serverside language.
Which would you rather do?
For reference, that part of the URL is called the 'query string'.
Server side langauges often have simplified interfaces to access the 'variables' in a query string. Javascript has no such interface; but it is possible to get reference to the entire URL of a page (address + query string), and to split that down into its component parts.
An example is here:
http://www.activsoftware.com/code_sa..._in_JavaScript
(That's a somewhat wasteful procedure if you want to repeatadly get at the different variables in a query string; but its not too bad if you have alot of potential variables and are only interested in a few of them)
Which would you rather do?
For reference, that part of the URL is called the 'query string'.
Server side langauges often have simplified interfaces to access the 'variables' in a query string. Javascript has no such interface; but it is possible to get reference to the entire URL of a page (address + query string), and to split that down into its component parts.
An example is here:
http://www.activsoftware.com/code_sa..._in_JavaScript
(That's a somewhat wasteful procedure if you want to repeatadly get at the different variables in a query string; but its not too bad if you have alot of potential variables and are only interested in a few of them)
If it only works in Internet Explorer; it doesn't work.
With PHP you simple use the
$_GET['variable'];
Variable. For example if you had a link
www.daniweb.com/fakeurl.html?id=12
Your PHP would be:
this would output 12
$_GET['variable'];
Variable. For example if you had a link
www.daniweb.com/fakeurl.html?id=12
Your PHP would be:
<?php $id = $_GET['id']; echo $id; ?>
this would output 12
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation:
Rep Power: 5
Solved Threads: 48
•
•
•
•
You can do it only with php.
PHP does it through Zend, which does it through C++; and it's delivered into an application's environment by the server software; so clearly, you can access it using other means than only PHP.
I'm sure you meant something different; and I don't mean to bite your head off; but there's a full wealth of ways in which you can access that data, PHP is one way to do it.
If it only works in Internet Explorer; it doesn't work.
![]() |
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- multiple variables in a mod_rewrite URL string (Linux Servers and Apache)
- Floating IP Address in AOL (PHP)
- truth table to boolean algebraic equation (Java)
- Using Search Engine Friendly PHP URLs (PHP)
- SQL Injection Attack (Database Design)
Other Threads in the HTML and CSS Forum
- Previous Thread: DreamWeaver 8: FTP information does not save for sites
- Next Thread: how do i perform these calculations without writing redundant code?


Hybrid Mode