Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
reference items after a question mark in a url
Old 07-22-2009, 11:32 PM reference items after a question mark in a url
Experienced Talker

Posts: 41
Trades: 0
im using links like
<a href="exsample.php?1">
<a href="exsample.php?2">
<a href="exsample.php?3">
<a href="exsample.php?4">
how can i refrence the number after the question mark
flatrat is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-23-2009, 01:09 AM Re: reference items after a question mark in a url
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Normally parameters passed via url are given a name. If your urls were formatted like this:

Code:
http://site.com/example.php?id=4
you could just grab the id variable from the url:

PHP Code:
$id $_GET['id']; 
If you insist on not specifying the parameter name then you have one of two options (that I know of). The first would be to use .htaccess to have
Code:
example.php?1
redirect to
Code:
example.php?id=1
or you can parse the url manually:
PHP Code:
$uri $_SERVER['REQUEST_URI'];
$len strlen($uri);

$var;
for(
$i 0$i $len$i++)
{
     if(
$uri[$i] == '?')
     {
          
$var $uri[$i 1];
          
$i $len;
     }

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 07-23-2009 at 01:11 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-25-2009, 06:04 PM Re: reference items after a question mark in a url
Junior Talker

Posts: 4
Trades: 0
You would usually have variables, but as the person above me said, you could use .htaccess to automatically add the id in.
MarginalLiaison is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to reference items after a question mark in a url
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23566 seconds with 12 queries