Jump to content

PHP code help


mattyt81

Recommended Posts

Hi

 

I have two html multi list boxes side by side, in the left box which has an ID of venueFrom I have the options (<option></option>).

 

The right box which has an ID of venue is blank.

 

I am using javascript to move selections from (venueFrom) to (venue) which works fine.

 

When I hit submit the selections get submitted to mysql table and are stored in the relevant field which is venue.

 

The problem I can't seem to fix is keeping the selected data in the (venue) multi list box after it has been submitted.

 

I have tried various bits of code they I have written and other people have suggested but it doesn't work.

 

I am currently at work so unable to paste all the code, but I think there should be enough information here.

 

The field in mysql table that (venue) is being stored in, is a text field, I don't think this should matter, but I am not a PHP expert.

 

Any help will be appreciated as its someonthing I should have sorted out myself by now, ut just can't crack it!

 

Link to comment
Share on other sites

Here's how I would do it:

 

I would declare two variables:  $venue and $venueFrom.  I would make them empty strings, like this:

 

$venue = $venueFrom = '';

 

Then I would collect the POST values of the two drop down menus:

 

$venue = $_POST['venue'];

$venueFrom = $_POST['venue'];

 

Then, in the drop down menu I would add the following:

 

<select>

<?php

if ($venue != '')

{echo '<option>' . $venue . '</option>';}

?>

<option>Milk</option>

<option>Coffee</option>

<option>Tea</option>

</select>

 

I'm pretty brain dead at the moment, but that's how I've done it in the past, I think.  Good luck.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.