473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

session info and pull down lists

hi

i have a html pull down list (<SELECT etc etc <OPTION VALUE .....) and
i have the particular value the user last chose it to be in a
$_SESSION['value']. How do i set the selected item of the list to this
one? I can just add it in as the selected item of the list but then it
appears twice. Get me? lol, hope so.

cheers
dave

Jul 17 '05 #1
1 1542
On 15 Sep 2004 05:56:10 -0700, ma**********@hotmail.com wrote:
hi

i have a html pull down list (<SELECT etc etc <OPTION VALUE .....) and
i have the particular value the user last chose it to be in a
$_SESSION['value']. How do i set the selected item of the list to this
one? I can just add it in as the selected item of the list but then it
appears twice. Get me? lol, hope so.

cheers
dave

Put it in a loop:

<?php
$foo = array(
'stuff' => 'for',
'select' => 'box'
);
?>

<select name="foo">
<?php
foreach ($foo as $key => $value) {
?>
<option value="<?php echo $key;?>"
<?php
echo ($_SESSION['value'] == $value) ?
'selected="selected"' :
'';
?>
/>$value</option>
<?php
}
?>
</select>
Formatted above to fit within news client easier.

You can change the line:
echo ($_SESSION['value'] == $value) ?

to

echo ($_SESSION['value'] == $key) ?
if looking for a key match rather than value.
HTH =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
4
by: Cowboy \(Gregory A. Beamer\) | last post by:
Background: ------------- The idea started as a single sign on type of application. Having tested it before, I knew we could institute single sign on using the same Authentication Cookie name (in...
5
by: VB Programmer | last post by:
I often use session variables to store the user's security level, and other important info. How secure are session variables? Can someone decrypt it and get the information? (This would be...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
2
by: Nick | last post by:
What I want to do is have 2 pull down lists, for example a state pull down list and a city pull down list. What I would like to have done is when you select a state from the state pull down list...
3
by: codegreen9 | last post by:
Hi, My understanding is that session info must be stored using Session, which means text data. What I'd like to be able to do, is keep an object alive throughout a user's session, without...
1
by: Hans Kesting | last post by:
Hi, Is it possible to share sessions between subdomains? Say: the user logs in at www.company.com, and is redirected to my.company.com. This is a different url for the same application. Can I...
2
by: ras26 | last post by:
I have a WebSite "App1" which has an external assembly "Lib1". Inside this external assembly we have developed some classes that derive from "System.Web.UI.Page". One of these pages is called...
5
by: The Cool Geek | last post by:
I'm building a dynamic site that has 3 data bases. One DB contains all of my store info ID#, Name, Address, Phone. Another DB contains member info ID, Name, address, email,phone,etc... The 3rd DB...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.