Jump to content

Recommended Posts

MySQL v4.1.21-standard

PHP v4.4.4

 

Occasionally, this works. Most of the time it doesn't. This may be more of a MySQL problem than PHP - I don't know for sure.

I have a drop-down box with two selections; ON and OFF that I store in a field of an SQL table that only holds one record. The idea is that the user makes a selection, the database record is updated, and that selection becomes the default. Except on a rare occasion, the database is not updating. Here is the code:

In the HTML Head section:

if (isset($_POST['VacStatus']))
{
   $query="UPDATE ColumnData SET VacOption = $VacStatus WHERE RecNo = 1";
   mysql_query($query);
}

Then the database is queried and field values are stored in an array called "PageVars".

Then the DropDown:

<form style="margin-top:0;" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
   <select name="VacStatus" onChange="submit()">
      <option <? if($pageVars[VacOption] == "ON"){echo "selected ";} ?> value="ON">Active</option>
      <option <? if($PageVars[VacOption] == "OFF"){echo "selected ";} ?> value="OFF">Inactive</option>
   </select>
</form>

 

Seems to me this should work. :? 

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.