Microsoft
Software
Hardware
Network
Question : Using querystrings with PHP
Hello,
I used to program in ASP all of the time but never PHP.
Assume the following is a static HTML page. What would the page look like in PHP to allow the content to be changed based on the querystring (i.e. variable X)?
Assume the URL is:
www.domainname.com/index.p
hp?x=1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3c.org/TR/199
9/REC-html
401-199912
24/loose.d
td
">
<HTML>
<HEAD>
<TITLE>Title Goes Here</TITLE>
</HEAD>
<BODY>
<P>Hello world!</P>
</BODY></HTML>
I want the .php page to have an array that's defined with the following values:
1="Hello blue world!"
2="Hello red world!"
3="Hello green world!"
4="Hello purple world"
If a querystring exists and has a value found in the array, then it will display one of the array values shown above. If it's not found, then it will display "Hello world!".
What does the final PHP code look like (including any tags needed to "initiate" PHP like ASP's <% %> tags)? In other words, please supply code that starts with <!DOCTYPE... and ends with whatever ending tag is needed at the end of the php page.
I appreciate your help!
Best regards,
Dan
Answer : Using querystrings with PHP
In the switch() statement, add a "default:" statement just like the "case:" statements.
See
http://php.net/manual/en/c
ontrol-str
uctures.sw
itch.php
Random Solutions
Batch File Script Issue
Change networks for server build
Solving a puzzle geocache
load a form base on a selectipon from a dropdown list
Where can I find the video bios update for this video card?
Create array based on variable value with javascript
Non Domain Users Accessing a Share on a Domain server
How to solve run-time error 459 on referencing a form still being loaded but not quite opened yet?
Loading Multiple RSS feeds into specific Divs
Form seems like it is hang during Directory.Getfiles on a large directory structure.