• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Display text based on POST variable

Perhaps I'm having a brain lapse but i cannot get a variable to work.  I want to post text based on what the POST variable is.  I am using the code below.

 
<?php
			// Get Quarter to show report selected 
			
			if($_POST['qSelect'] = '1') { $quart = "First Quarter"; }
			elseif($_POST['qSelect'] = '2') {$quart = "Second Quarter"; }
			
			?>

Open in new window


I am then using the $quart variable to display the user's choice.
0
axessJosh
Asked:
axessJosh
1 Solution
 
Rik-LeggerCommented:
<?php
                  // Get Quarter to show report selected
                  
                  if($_POST['qSelect'] == '1') { $quart = "First Quarter"; }
                  elseif($_POST['qSelect'] == '2') {$quart = "Second Quarter"; }
                  
                  ?>
0
 
haloexpertsexchangeCommented:
rik is right, your problem is the = you used in the if statement, instead of the ==. Remember in php = is for assigning values to a variable, == is for comparison. So what you are doing in the if statement is assigning first 1 to $_POST['qSelect'] then assigning it 2 instead of checking the values.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now