Jump to content

droplists/database values/sessions


rbragg

Recommended Posts

I have many droplists that are populated with the values "open" and "closed". This one is called drop31. As with all of the droplists, which value is default is dependent on which value is currently stored in the db under "Lot31":

<?php
include 'db_connect.php';

$query_getStatus = mysql_query("SELECT * FROM park_lots") or die(mysql_error()); 
$get_status = mysql_fetch_array( $query_getStatus );

$_SESSION['status'] = array('open','closed');

echo "<select name='drop31 id='31' class='style1'>";
for ($i=0;$i<=count($_SESSION['status']);$i++) 
{
  if ($_SESSION['status'][$i] == $get_status['Lot31']) {
    echo "<option value=\"{$_SESSION['status'][$i]}\" selected=\"selected\">{$_SESSION['status'][$i]}</option>";
  } else {
    echo "<option value=\"{$_SESSION['status'][$i]}\">{$_SESSION['status'][$i]}</option>";
  }
}
echo '</select>';
?>

The user can change the the value and then upon submission is transferred to a confirmation page where the new value is displayed. This is where my problem is. How do I display the new value there via the Sessions array? I have set up the array at the top of page like so:

<?php if( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['done']) )
{
  foreach ($_POST as $key => $value)
  {
    if ($key != "done")
    {
       $_SESSION[$key] = strip_tags($value);
    }
  }
  header("Location: lots_admin_result.php");
}?>

I had this working before I implemented the db aspect.

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.