Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Don't understand the concept !

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Let me try and explain my situation to the best of my ability

I have 3 steps to my registration phase

Step 1 : Select Values from 3 drop down lists

Step 2 : Enter Location details

Step 3 : Contact details

A submit button on step 3 that enters values into a mysql database.

Now what I want to do is give the users the option of being able to

Select more than once on step one, perhaps a button that says click to register

Further items, so that let’s say they have registered 3 times they only have to go

Through step 2 and step 3 once.

As it stands it works fine if you only want to register once in step 1

I carry the values as session variable to the next stage, but how can you pass mutlple

session variables from the same page.

I am new to this stuff and this kind of concept.

I hope you understand what I mean

Any guidance would be appreciated
 
The browser will pass the session for you automagically!

If you have the:
Code:
multiple="multiple"

inside your <select name...
(at the very end)

The user can then select multiple items in one list!
The name of the <select>, will then be an array!

Code:
for($i = 0; $i < count($_SESSION['foo']; $i++) {
  echo $_SESSION['foo'] . "<br />";
  }

eg. your <select> has to look something like:
Code:
<select name="foo" size="5" multiple="multiple">
  <option value="val0" selected="selected">bar zero</option>
  <option value="val1">bar one</option>
  <option value="val2">bar two</option>
  <option value="val3">bar three</option>
  <option value="val4">bar four</option>
</select>

If you wish to then display what is selected before, as selected now, you need to generate the select with php!

How do you do this??

it's very simple.. Make an array, where keys => values
Then you loop it, and compare the value of the key, with values from the $_SESSION['foo']. If they match, add selected="selected" at the end of the opening <option>.

I hope you understand what I'm aiming at here.
If you need more information, I might give you an example of how to compare two arrays in a loop, while generating <options> in the <select>.

Olav Alexander Mjelde
Admin & Webmaster
 
sorry,
Code:
for($i = 0; $i < count($_SESSION['foo']; $i++) {
  echo $_SESSION['foo'] . "<br />";
  }

should be something like:
Code:
for($i = 0; $i < count($_SESSION['foo']; $i++) {
  echo $_SESSION['foo'][$i] . "<br />";
  }

ps. might be more bugs :p it's coming from my rotten brain

Olav Alexander Mjelde
Admin & Webmaster
 
Tks for the answer i'll give it a try tonight
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top