Solved

PHP- why does this not select the posted value?

Posted on 2006-06-26
2
252 Views
Last Modified: 2010-04-17


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<form action="testy.php" method="post">
<select name="listname">
<option value="php3"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected" '; }?>> PHP 3</option>

<option value="php4"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected"'; }?>> PHP 4</option>

<option value="php5"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected"'; }?>>PHP 5</option>

</select>

<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>
0
Comment
Question by:roscoeh23
2 Comments
 
LVL 3

Accepted Solution

by:
AndyWHV earned 500 total points
ID: 16982885
The Problem is the login in the if structure...

look at
if ( (isset($_POST['listname'])) && ($_POST['listname'] == 'php3') )

you check for php3 every time.

Greetz
Andy ;-)
0
 
LVL 2

Expert Comment

by:T3Logic
ID: 16984016
<option value="php3"<? if(isset($_POST['listname']) == 'php3'){echo  ' selected = "selected" '; }?>> PHP 3</option>

<option value="php4"<? if(isset($_POST['listname']) == 'php4'){echo  ' selected = "selected"'; }?>> PHP 4</option>

<option value="php5"<? if(isset($_POST['listname']) == 'php5'){echo  ' selected = "selected"'; }?>>PHP 5</option>
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 66
ClickOnce Install - Shortcut Question 3 58
White board coding practice 3 61
move one pixel 4 41
This article will show, step by step, how to integrate R code into a R Sweave document
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

15 Experts available now in Live!

Get 1:1 Help Now