Solved

Display text based on POST variable

Posted on 2011-09-27
2
200 Views
Last Modified: 2012-05-12
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
Comment
Question by:axessJosh
2 Comments
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 250 total points
ID: 36710673
<?php
                  // Get Quarter to show report selected
                  
                  if($_POST['qSelect'] == '1') { $quart = "First Quarter"; }
                  elseif($_POST['qSelect'] == '2') {$quart = "Second Quarter"; }
                  
                  ?>
0
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36710692
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
object oriented programming comparison 5 54
unset shopping cart session 15 31
highcharts wont fix inside a bootstrap modal window 6 30
WP_Query multiple custom taxonomies 5 28
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now