Solved

Display text based on POST variable

Posted on 2011-09-27
2
199 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

759 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

16 Experts available now in Live!

Get 1:1 Help Now