General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 18th, 2003, 11:08 AM
bsk bsk is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 1 bsk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
conditional statement

i am new to php and have been using cold fusion. i need to find how to do the same thing in php that i have in cold fusion. here is the cold fusion code:
<cfparam name="action" type="numeric" default="1">
<cfif action is 1>
enter text here
</cfif>
<a href="#path_info#?action=3"></a>
<cfif action is 2>
enter text here
</cfif>
<a href="#path_info#?action=3"></a>

all this does is allow you to create different sections within each page so you don't have to create new pages to link to but you can just call up certain parts of the page. i found how to use the if, else, else if statements in php but i can't find a way to create a variable that it's value can change like this. What tag is there to use like the cfparam so i can create a new variable like that? thanks!

Reply With Quote
  #2  
Old March 18th, 2003, 01:28 PM
rheroux rheroux is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 2 rheroux User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well, here's a simple three layered script that displays different text based upon clicking one of the two links:

PHP Code:
<?php


if($_GET['action'] == '2')
{
echo 
'Your action is 2.';
}

elseif(
$_GET['action'] == '1')
{
echo 
"Your action is 1";
}

else
{
echo 
'Click a link below.<br><br>';
echo 
'<a href="test.php?action=1">Click me!</a><br><br>';
echo 
'<a href="test.php?action=2">No, click me!</a><br><br>';
}
?>


So, all that's happening is you are embedding action into the URL and assigning it a value of 1 or 2. Based upon that, the script will display "Your action is 1" if $_GET['action'] is equal to 1, or "Your action is 2" if $_GET['action'] is equal to 2.

You could use just $action instead of $_GET['action'] but it's highly recommended to use the $_REQUEST array with PHP now.

Last edited by rheroux : March 18th, 2003 at 01:37 PM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > conditional statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway