Jump to content

Recommended Posts

Is this scenario possible:

 

I have a database that has customers in it.  When they purchase things from me, each purchase is either "online" or "onsite".  So a selection must be made as either "online" or "onsite" when the item is entered into the database.  Often, I have to update this value for an item later on from "online" to "onsite" and vice versa.  Is there anyway to populate the "Type" field with whatever the value is in the datablse for this particular item purchased, then allow someone to select "online" or "onsite" from the dropdown if it needs to be edited?

It would look something like this:

Item Number (primary key) | Customer ID | Cost | Type (online or onsite)

            7897                        4              $3            online

 

The code below is kind of how I would envision it working, but have had little luck finding a good example in the forum or online anywhere.  Any help would be greatly appreciated.

 

<TD width=98 height="29" align="center"><select name='add_OnlineOnsite' value='default value from Type Field in DB'>
<option value="Online">Online</option>
<option value="Onsite">Onsite</option>
</select></td>

Here is what I ended up doing and it works.  Thankfully. 

 

Would enum make this more efficient?

 

<?
include("dbinfo.inc.php");

mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = mysql_query("SELECT OnlineOnsite FROM items WHERE Buyer=$Buyer AND SellingDate=$SellingDate AND ItemID=$ItemID") or die(mysql_error());

while ($row = mysql_fetch_assoc($query))
{
echo '<select name="ud_OnlineOnsite">';
echo '<option'.($row['OnlineOnsite']=="Online"? ' selected' : '').'>Online</option>';
echo '<option'.($row['OnlineOnsite']=="Onsite"? ' selected' : '').'>Onsite</option>';
echo '</select>';
}
?>

 

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.