PHP Classes

php and dropdown box

Recommend this page to a friend!

      PHP IOC  >  All threads  >  php and dropdown box  >  (Un) Subscribe thread alerts  
Subject:php and dropdown box
Summary:Filtering dropdown box listing
Author:D T
Date:2006-10-04 01:31:50

  1. php and dropdown box   Reply   Report abuse  
D T - 2006-10-04 01:31:50

Hi I am trying to get data from a mysql database with php.
These dynamic rows may have multiple prices between 1 and 5.
I would like to use a drop dropdown to display these prices and
allow the user to select the one that apply.

//This works
if ($searching =="yes" && $phrase_count > 0)
//search for our search term, in the field the user specified
//search for description and code in bill_ohip_fee_code and
service fee in bill_on_curr_master
$data = mysql_query("SELECT c.code_id, c.fee_code, c.description,
m.general_fee, m.technical_fee, m.specialist_fee,
m.anesthestist_fee, m.non_anesthetist_fee
FROM bill_ohip_fee_code c, bill_on_curr_master m
WHERE c.fee_code = m.code
AND upper(c.$field) LIKE'%$find%'
AND c.section_code = '$services'
ORDER BY (c.$field)
LIMIT 100");

while($row = mysql_fetch_array($data))
$code_id = $row['code_id'];
$fee_code = $row['fee_code'];
$description = $row['description'];
$general_fee = $row['general_fee'];
$technical_fee= $row['technical_fee'];
$specialist_fee= $row['specialist_fee'];
$anaesthetist_fee= $row['anesthestist_fee'];
$non_anaesthetist_fee= $row['non_anesthetist_fee'];

//determine length of values
$gen_len = strlen($general_fee);
$tec_len = strlen($technical_fee);
$spec_len = strlen($specialist_fee);
$ana_len = strlen($anaesthetist_fee);
$non_len =strlen($non_anaesthetist_fee);

//format fee to 2 deciaml places
$general = sprintf("%9.2f",$general_fee/100);
$technical = sprintf("%9.2f",$technical_fee/100);
$specialist = sprintf("%9.2f",$specialist_fee/100);
$anaesthetist = sprintf("%9.2f",$anaesthetist_fee/100);
$non_anaesthetist =

/************drop down not filtering*************/
//this is not working
//this is the dropdow box info put into an array for use
//use below
$fee = "<select name=\"fee[]\">
if($gen_len > 0)
<option value = $general> $general</option>
if($tec_len > 0)
<option value = $technical> $technical</option>
if($spec_lent > 0)
<option value = $specialist> $specialist</option>
if($ana_len > 0)
<option value = $anaesthetist> $anaesthetist</option>
if($non_len > 0)
<option value = $non_anaesthetist> $non_anaesthetist</option>

//this works
//diaplay search results in rows
echo"<tr height=\"10\">
<td width=\"4%\" bgcolor=\"#fff8dc\" align=\"center\"><input
type=\"checkbox\" name=\"fee_choice[]\"
<td width=\"6%\" bgcolor=\"#fff8dc\"><span class=\"style20
<td width=\"3%\" bgcolor=\"#eeeee0\" height=\"10\">
<input type=\"text\" name=\"fee_unit[]\" size=\"1\"
maxlength=\"2\" value =\"$fee_unit\"/></td>
<td width=\"80%\" bgcolor=\"#eeeee0\" class=\"style20\">
$description </td>
<td width=\"5%\" align=\"left\"> $fee </td>\n";