Jump to content

Recommended Posts

Ok, here I am again with another question that, if I could get answered would save me alot of time. Heres the scenario if you woud...

 

On my crime stoppers website, you have the option to add a crime through forms and a database, easy, right. Well, when the user wants to add a crime to the website, they have to select from this drop down menu/list box, the type of crime it is. This list box's values are all dynamic because the types of the crimes are stored in another table so that as the need arises, instead of having me add a type of crime through code, and updating every page that has this list box, they can add it themselves. Well. The problem arises when they go to make a change to a crime that they added, how do I make it so that the type of crime they selected, is still selected when they get to the page. I was wondering if anyone has ran into this before and found a solution.

Thanks in advance guys.

Link to comment
https://forums.phpfreaks.com/topic/113325-dynamic-list-box-selected-help/
Share on other sites

your database should be holding an ID for the Crime Type:

 

original form would hold the value as the type ID, ( or name), and display the name

 

On the form that your editing with.  when looping through crime types - you just need to compare against eh database first ( assumign youve already got eh user data out:

 

echo "<option value ='".$CrimeType...... ";

if($Crime_Type['Type_ID'] == $Data['Crime_Type']) {

echo "selected = 'selected' ";

}

 

 

 

 

gdlk

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.