• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • 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.

			// 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.
1 Solution
                  // Get Quarter to show report selected
                  if($_POST['qSelect'] == '1') { $quart = "First Quarter"; }
                  elseif($_POST['qSelect'] == '2') {$quart = "Second Quarter"; }
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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