Jump to content


help with php list box

  • Please log in to reply
1 reply to this topic

#1 rsammy

  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 11 September 2006 - 08:36 PM

i am working on a php app. i need to populate a list box(drop down) with three values(not from db) like 'ALL', 'ACTIVE' and "INACTIVE'.

when 'ACTIVE' is chosen from the list box, i need to check one table in the db and get all the info from the table based on a certain criteria. if INACTIVE is chosen, then another table is searched and infor from that table needs to be displayed. ALL displays values from both tables.

Lemme make it clearer:

I have two tables: admission and admit_status. the admission table has a field called discharge_date. as long as the patient is admitted, this field shows '00-00'0000' as the date. it is updated with the date when the patient is discharged. while this date is being updated, the patients info(such as, location, reason, room_no, admit date, etc.) is deleted from theadmit_status table.

I am checking on a patient activity summary report. in this report, i need to see all those patients who are either "ACTIVE' or "INACTIVE'. ACTIVE means the patient is still active in the hospital(admitted state and his discharge_date in the admission table is still '0000-00-00'.

If the I choose INACTIVE from the drop down, the those patients who have been discharged and not active (or admitted in the hospital) - whose info has been deleted from the admit_status table - need to be displayed.

ALL -should display all patients irrespective of their status.

hope i am clear here. any help will be appreciated. THANKS

#2 gijew

  • Members
  • PipPipPip
  • Advanced Member
  • 240 posts
  • LocationCalifornia

Posted 11 September 2006 - 11:05 PM

Well if you're looking to have it done automatically you're going to need to use AJAX which can do your queries without refreshing the page.  It's a lot more to learn and it takes time and well, I'm angry at it right now.

If you want a drop down with your 3 options and a submit button, I may be able to help.

If this were me though, I would change 'all','active','inactive' fields to '0','1','2' for that inner nerd in me.  The rest is fairly simple.

<form action="results.php" method="post">
  <select name="patient_status" size="3">
    <option selected="selected">Patient status</option>
    <option value="0">All</option>
    <option value="1">Active</option>
    <option value="2">Inactive</option>
  <input type="submit" value="Fetch" />

if ($_POST['patient_status']) {
  $checkStatus = mysql_query("SELECT field1, field2 FROM table WHERE status = $_POST[patient_status]") or die (mysql_error());

if (mysql_num_rows($checkStatus) == 0) {
  // nothing was returned, fail
} else {
  while ($patient = mysql_fetch_array($checkStatus)) {
    // list patients

That's the basics of it all but it should get you started or at the very least, occupied.  I use Adodb so my basic mySQL is kind of rusty, sorry for any errors there.
I'm considered good looking in some countries

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users