473,884 Members | 2,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple select box population

10 New Member
So i have this portion of code

Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="insert_disease_has_symptom_db.php" onsubmit="multipleSelectOnSubmit()">
  2. <select multiple name="fromBox[]" id="fromBox">
  3.     <option value="1">Sintoma 1</option>
  4.     <option value="2">Sintoma 2</option>
  5.     <option value="3">Sintoma 3</option>
  6.     <option value="4">Sintoma 4</option>
  7.     <option value="5">Sintoma 5</option>
  8.     <option value="6">Sintoma 6</option>
  9.     <option value="7">Sintoma 7</option>
  10.     <option value="8">Sintoma 8</option>
  11. </select>
  12. <select multiple name="toBox[]" id="toBox">
  13. </select>
  14. <input type="submit" value="OK">
I am to populate my option values with names on a table in a sql, storing afterwards the ids of the selected names that i passed to the right. Any ideas, because im stuck :\
Nov 16 '08 #1
23 5251
6,050 Recognized Expert Expert
I don't understand. Can you explain a little more?

Also, you'll notice I've formatted you code. Please, when posting code, wrap it in [code] tags. Just higlight the code, and hit the '#' button at the top of this editor.

Nov 16 '08 #2
5,821 Recognized Expert Expert
Heya, toshibata.

Try print_r()'ing $_POST after you submit the form, and you'll see what data has been input.
Nov 16 '08 #3
10 New Member
Im trying to populate those option values with info stored on my database, but since this is the first time im doing a multiple select box where you have to select from the left box (which will contain all attributes) the attributes you which tou chose passing to the right box.

After Submiting it should store on a different table the id of the attributes i selected.

Managed to get this working on a scroll down type thing, but that only allows me to chose one attribute at a time, so im stuck :\

Any help would be most appreciated
Nov 25 '08 #4
1,584 Recognized Expert Top Contributor
I'm still a little lost.

Explain it more in the means of the application, what is this page support to help the user do.

From the what it looks like you're trying to have the user select one (or more) symptoms from the first drop down or multi-select box, based on their choices you want to display the diseases that cause these symptom and have the user select one (or more?) of these diseases or illnesses?

Let me know if this is what you want to do.

Nov 25 '08 #5
10 New Member
No, i wish to populate with symptoms which are on my database, selecting the ones that are on that specific disease, saving after that the ID of those symptoms in the database.

Hope i made myself clear
Nov 26 '08 #6
1,584 Recognized Expert Top Contributor
Well, that was assumed. I'm not actually asking you to have the symptom box hard-coded, it would be pulled from the database (list of all symptoms).

I don't know what you mean by "saving after that the ID of those symptoms in the database." It's not a complete sentence.

Is this for a doctor that assigns the symptoms to a disease or for visitors who wish to find out with disease is causing their symptom by indicating those symptoms on the site?

Also: I've seen a similar application on web MD. The list of symptoms are too large for a single drop down. They at least need to be categorized.

Here's an example at WebMD:

Symptom Checker

I'm trying to find out what your trying to do so I can help you achieve it.

Nov 26 '08 #7
10 New Member
Ill try to explain in more detail and as well as i can.

I have a database for a clinic. And the objective is to make mini-appications in PHP to insert data. One of those insertions ( The one im having problems with ) is to insert diseases, making a form asking for its details, inserting it after in the database. After that disease has been inserted, i have to use a multiple select box in which on the left part will be all the symptoms i have stored on the symptoms table on my database. From which ill choose the symptons present on the disease i inserted into the database on the previous step, moving them to the right box and clickling submit. This will then store in a table name disease_has_sym ptom a tuple of the id of the disease and the symptom.

Tried to be as clear as possible, hope you understand the issue as this is burning my brain :>

Might aswell post an image of the tables of the database maybe will make my point more clear.

Nov 26 '08 #8
7 New Member
I don't see, given the code provided, how users move the selected symptoms from the complete list (fromBox[]) to the short list on the right (toBox[]). If, on submit, nothing has been added to the toBox (and subsequently selected), then on the post your toBox[] field will be empty.

Presumably you could do this with just the one multiple select box, so perhaps it's a matter of design/taste to use the "all available -> selected" model. If you have just the one fromBox, the selected items should come through on the POST and you'll have your list.

If you do want the two boxes, you probably need either some drag and drop functionality, or at least a button to move items from the left to the right (and back again) and then, before submitting, make sure to select all the items in the right box, because just having the options won't help unless they're selected.

Of course, maybe you did all that and just didn't put it in your code sample. In which case I probably didn't help with the brain burning thing.
Nov 26 '08 #9
1,584 Recognized Expert Top Contributor
Ok here's what I understand. You need to give the user a way to add a disease to the disease table and then have them select the symptoms (from the list you already have in the database) that apply to that disease. Then you save this link in the table you specified. the relationship of the disease and symptom table is a many to many relationship, ie. one or more disease match up to one or more symptoms, obviously.

here's what I would do. You don't need to give the user two pages. It can all be done in one. Give the user the form fields for the name of the disease, its description, etc and right below it, display a multi-select box with all your symptoms where they can select multiple symptoms. Once they hit submit, You'll grab the data, create the disease (after appropriate validations) and insert it into the database. Once you insert it, you can call the mysql_insert_id () and be presented with ID (or primary key value) of that disease.

You then create an entry in the disease_has_sym ptom table by inserting all the symptoms that disease has. (I'm assuming the multi-select box above will have the symptom ID (primary key) as the value, and the name as the label.

Here's how you populate the symptom mult-select box:
Populate Select Box - PHP and MySQL | Tech-Evangelist

Let's go back to your original question. Which part of this page you don't know how to do?
Nov 26 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Megan | last post by:
Data Comparison: Sample Versus Rest of Population. I have a population of data, and I want to take a sample of that population and compare it against the entire population. I have a database that records information about the types of Rulings a person receives. Each person works for an agency, and there are 12 agencies (see example below). Each person receives a ruling, and there are 2 types of rulings,
by: Tarvos{k} | last post by:
Okay folks, I am back with another somewhat weird problem. I have a table that I am trying to run a query on that has the following fields: City, State, Zip Code, Population, Households. The info for the table came from US Census information for 2000, and what I need is to find the number of times a particular entry repeats. Example: I want to find the number of times a city name shows up, and the number of states it shows up in.
by: Jeff Gardner | last post by:
Greetings: I have a table with 3 pieces of data that I would like to use to dynamically populate 3 drop downs using javascript. The fields are state, orgname, office. If it's not already obvious, I'd like orgname drop down to change when a state is selected and I would like office drop down to change when an orgname is selected. I can do this with multiple tables but am having difficulty getting it to work when the data is in the...
by: neonman14 | last post by:
Hello I am in Intro to Java Programming and I am having problems with assignment. The Homework assignment is called Population. Population Write a program that will predict the size of a population of organisms. The program should ask for the starting number of organisms, their average daily population increase (as a percentage), and the number of days they will multiply. For example, a population might begin with two organisms, have an...
by: Supermansteel | last post by:
I have a query that counts how many results are in each branch out of 5000 rows. I am trying to condense even further and only show the Top 2 Branches in every State (so should reflect 100 results, theoretically). Is there a way to get this done? SELECT Format(a.,"mm/""01""/yy") AS Date_ID, a.STATE, a.Branch, Count(a.Branch) AS Branch_Totals FROM AS a GROUP BY a.STATE, a.Branch, a.
by: Igor | last post by:
Hello I have the following problem. I have three drop down lists on my page. They are filled with data from a database. Initially only the first one is enabled. The next one is enebled when user selects an item from the first one -- it is then filled with data specific to the selection in the drop down list above. The same with the third one. For each drop down list the first item is always "--select an item--" (as described here:...
by: Andrew Meador | last post by:
I have searched and found where this has been discussed, but the suggestions I have found have all ended up tuning into debated about whether it needs to be done - but - as far as I can tell - I need to. I am trying to setup a database that tracks parcel history. I want to be able to choose a parcel and see a list of its children (smaller pieces to the property that have been sold off) and a list of its parents (previous tracts/parcels...
by: Clive Swan | last post by:
Hi I am trying to sum a population field that may have 140 records for each Ward (example). Any suggestions on the best way to do this. I would like to have a unique record for each Ward with all the records summed.
by: tg | last post by:
http://img522.imageshack.us/img522/8647/scan10005ci7.jpg As a percentage of world inhabitants, the white population will plummet to a single digit (9.76%) by 2060 from a high-water mark of 27.98% in 1950. The big population story of the 21st Century is shaping up to be the status reversal of whites and blacks and the Indian baby boom. A side bar will be the single digit minority role that whites will assume. Of the 7 population groups...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.