Guest kilbad Posted February 22, 2007 Share Posted February 22, 2007 I have a type of data (medication names) that I want a user to input into a form, and then have those medications listed in a MySQL db in separate columns for each particular patient; so one row would look like: Patient's Chart Number | first medication | second medication | third medication | and so forth.. My question is this: What is the best way, using PHP and/or javascript to have a user input multiple medications in a form when there is a different/undetermined number of medications that will need to be entered for each patient. I don't want to have a form with a absolute number of text input fields because what if there are more medication than fields? I also do not what to delimit the data in a single input field with spaces, commas, etc, because each medication will also have additional input fields that will need to be filled out (frequency, dosage). Any ideas? I just want to make sure I am smart about the way I do this. Let me know if you need any clarification on what I have written. Thank you all so much in advance! Brendan Link to comment https://forums.phpfreaks.com/topic/39682-undetermined-number-of-data-items-what-is-best-method-of-input/ Share on other sites More sharing options...
JBS103 Posted February 22, 2007 Share Posted February 22, 2007 I am sure there is a Javascript/AJAX solution out there that will make a new text field appear as soon as a one is filled in. Sadly, I'm not the person to ask about that. In terms of the back-end, one possible solution is to store all the medication names in one field using commas, or any other character to seperate them. From there you can just use explode to break them up into separate array values <?php //Query returns something along the lines of $results = "Medication1|Medication2|Medication3"; $medcations = explode("|", $results); print_r($medications); ?> There might be a more practical solution. Link to comment https://forums.phpfreaks.com/topic/39682-undetermined-number-of-data-items-what-is-best-method-of-input/#findComment-191575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.