Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

passing multiple vars in url - possible?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

passing multiple vars in url - possible?

Postby tomboy12 » Fri Aug 29, 2003 3:57 am

I have a link that pass a variable link page

Code: Select all
print ' <a href="calendar_emp.php?to=1"><strong>calendar</strong></a>';


However I need to pass more than one variable. 3 variables must be passed to calendar_emp.php.
I cannot use form, cause I use a link as you can see and not a submit button.

Is it possible to pass more than 1 with url?
tomboy12
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue Jul 08, 2003 3:54 am

Postby liquedus » Fri Aug 29, 2003 4:20 am

you can pass more than one variable by using the & operand.

example

print ' <a href="calendar_emp.php?to=1&from=2"><strong>calendar</strong></a>';

to add on more vars use & :wink:
liquedus
php-forum Active User
php-forum Active User
 
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada

Re: passing multiple vars in url - possible?

Postby WiZARD » Fri Aug 29, 2003 4:22 am

Code: Select all
print ' <a href="calendar_emp.php?to=1&variable1=value1&variable2=valuse2"><strong>calendar</strong></a>';
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

url length

Postby ruturajv » Fri Aug 29, 2003 9:00 pm

you can pass as many variables you want,

but make sure what is the length of url that is supported by the browser, older browser support length upto 255 chars.

Swirlee do you know what is the length supported by latest browsers? i don't know!!
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby swirlee » Fri Aug 29, 2003 11:12 pm

There's no standard as to how long a URL should be, but according to this page at MS, IE (at least up to 5.5, which is a very popular version) supports URLs up to 2083 characters. I haven't a clue what the significance of this number is (as a CS kid I'm interested in this stuff) as it's 2^11+35, which doesn't seem mathematically significant at all. This page suggests the following lengths for other browsers (circa 5/03):

sidki3003 wrote:IE > 5: 2,083 (508 in IE 6.0)
Mozilla > 1.3: >20,000
Netscape 4.75: 1,848
Opera 7.x: 4,094


Interesting that IE6 brought the max length down to 508. Some URLs, like those from MapQuest, can get pretty damn long. It would be interesting to see a survey of average URL lengths for popular sites like Amazon, eBay, and MapQuest (though eBays URLs are refreshingly sane in length). By the way, the only number up there that doesn't appear to be mathematically arbitrary is Opera, which is just two shy of 2^12. Wonder what they do with the other two bytes. :D

Some URL length tests (in bytes):
Google Search for "neon pink": 65
MSN Search for "neon pink" (typed into IE address bar): 65
MSN Search for "neon pink" (typed in at search.msn.com): 58
eBay Search for "neon pink": 168
MapQuest Search for directions from Orlando, FL to Montreal, BC (a 61-hour drive): 149
Amazon page for 3M Post-it(R) Standard Flags, Neon Pink, Pack Of 2: 146
BN.com page for The Usborne Book of Decorating T-Shirts: 100
Search of IRS.gov for 1040EZ: 179
Monster.com search for "PHP" in New York City, NY in Internet/E-Commerce: 109
Monster.com page for a decent PHP job (check it out, I'm tempted myself): 153
URL as UI column at UseIt.com, from search page (cruel irony): 120

Alright, I was bored, so I came up with those. I was actually surprised by the MapQuest URL -- they used to be really, really long (e.g. wrapping 4-5 lines in an e-mail (80 cols)). Post your own if you find any ridiculously long URLs. Looks like the worst offender is the IRS. Surprise, surprise. :mrgreen: eBay's search URLs are long, but their actual auction pages have pretty short URLs.

Here's a good discussion of URL length that you should all consider in your projects: URLs Matter. A lot. (59)

Don't ask where the neon pink thing came from. It's late and it was the first thing that popped into my head.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby Joel » Sat Aug 30, 2003 2:21 pm

I really don't know why anyone would be using 500 characters.

I typed a whole lot of f's after a url in IE 6 and it stopped me after 271 but then i tried again by putting the cursor back a couple of characters and gave up at 1853.

Then I pressed enter and all of those 1853 characters were allowed to stay in. Mind you, the page toook a very, very long time to load (I added the f's onto the end of this "http://www.php-forum.com/p/posting.php?mode=reply&t=2925fffffffffffff")

I bet Internet explorer could fit a lot more too.

In Mozilla I gave up at 1375. When I pressed enter it sent the whole 1375 long URL through as well.

All in all I have wasted my morning.
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.