473,671 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[CLOSED] Filtering dropdown box

41 New Member
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.

I am having problems getting the dropdown to filter using the "if" statements.


//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_c ode and service
// fee in bill_on_curr_ma ster
$data = mysql_query("SE LECT c.code_id, c.fee_code,
c.description, m.general_fee,
m.technical_fee , m.specialist_fe e,
m.anesthestist_ fee,
m.non_anestheti st_fee
FROM bill_ohip_fee_c ode c, bill_on_curr_ma ster 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_arr ay($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_f ee= $row['anesthestist_f ee'];
$non_anaestheti st_fee= $row['non_anesthetis t_fee'];


//determine length of values
$gen_len = strlen($general _fee);
$tec_len = strlen($technic al_fee);
$spec_len = strlen($special ist_fee);
$ana_len = strlen($anaesth etist_fee);
$non_len =strlen($non_an aesthetist_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_fe e/100);
$anaesthetist = sprintf("%9.2f" ,$anaesthetist_ fee/100);
$non_anaestheti st = sprintf("%9.2f" ,$non_anaesthet ist_fee/100);


/************dro p 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_anaestheti st> $non_anaestheti st</option>
}
</select>";



//this works
//diaplay search results in rows
echo"<tr height=\"10\">
<td width=\"4%\" bgcolor=\"#fff8 dc\" align=\"center\ "><input
type=\"checkbox \" name=\"fee_choi ce[]\" value=\"$code_i d\"></td>
<td width=\"6%\" bgcolor=\"#fff8 dc\"><span
class=\"style20 "><strong>$fee_ code</strong></span></td>
<td width=\"3%\" bgcolor=\"#eeee e0\" height=\"10\">
<input type=\"text\" name=\"fee_unit[]\" size=\"1\" maxlength=\"2\"
value =\"$fee_unit\ "/></td>
<td width=\"80%\" bgcolor=\"#eeee e0\" class=\"style20 \"> $description
</td>
<td width=\"5%\" align=\"left\"> $fee </td>\n";
echo"</tr>\n";
}
Oct 4 '06 #1
6 1556
ronverdonk
4,258 Recognized Expert Specialist
Works fine with me. In order to track it, why don't you put an "echo $fee" statement right after the "</select>"; statement. That should give you a drop down box. You can then decode from there on.

Ronald :cool:
Oct 5 '06 #2
assgar
41 New Member
Works fine with me. In order to track it, why don't you put an "echo $fee" statement right after the "</select>"; statement. That should give you a drop down box. You can then decode from there on.

Ronald :cool:

Hi Ronald
Thanks for responding.

I don't undestand your suggestion could you demonstrate.

The dropdown will work and show all 5 listings and that is the problem. Some of the fees will be 0.00. I am trying to filter out the 0.00 fees from being in the dropdown.

assgar
Oct 6 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
First spec_len is incorrectly spelled (spec_lent).
What you basically do is combine logic and data in a data array. In order to get something like that working you need at least to use the eval() function. But it is better to just build up the $fee option list, as follows:
[PHP]$fee = "<select name=\"fee[]\">";
if($gen_len > 0)
$fee .= "<option value = $general> $general</option>";
if($tec_len > 0)
$fee .= "<option value = $technical> $technical</option>";
if($spec_leng > 0)
$fee .= "<option value = $specialist> $specialist</option>";
if($ana_len > 0)
$fee .= "<option value = $anaesthetist>$ anaesthetist</option>";
if($non_len > 0)
$fee .= "<option value = $non_anaestheti st> $non_anaestheti st</option>";
$fee .= "</select>"; [/PHP]

Good luck.

Ronald :cool:
Oct 6 '06 #4
assgar
41 New Member
First spec_len is incorrectly spelled (spec_lent).
What you basically do is combine logic and data in a data array. In order to get something like that working you need at least to use the eval() function. But it is better to just build up the $fee option list, as follows:
[PHP]$fee = "<select name=\"fee[]\">";
if($gen_len > 0)
$fee .= "<option value = $general> $general</option>";
if($tec_len > 0)
$fee .= "<option value = $technical> $technical</option>";
if($spec_leng > 0)
$fee .= "<option value = $specialist> $specialist</option>";
if($ana_len > 0)
$fee .= "<option value = $anaesthetist>$ anaesthetist</option>";
if($non_len > 0)
$fee .= "<option value = $non_anaestheti st> $non_anaestheti st</option>";
$fee .= "</select>"; [/PHP]

Good luck.

Ronald :cool:

Hi Ron

Thanks again.

A new way to build a dropdown.
This suggested approach does display a dropdown
box. unfortunately I am still getting fees with 0.00 showing,
the if statement is still not filtering out the 0.00.

Maybe I am trying the impossible,
but if can get the filtering working it would replace 2 X 40 = 80 lines of code.
Oct 8 '06 #5
ronverdonk
4,258 Recognized Expert Specialist
Then test the values of the division:
[PHP]$fee = "<select name=\"fee[]\">";
if(($general_fe e/100) > 0)
$fee .= "<option value = $general>$gener al</option>";
if(($technical_ fee/100) > 0)
$fee .= "<option value = $technical>$tec hnical</option>";
if(($specialist _fee/100) > 0)
$fee .= "<option value = $specialist>$sp ecialist</option>";
if(($anaestheti st_fee/100) > 0)
$fee .= "<option value = $anaesthetist>$ anaesthetist</option>";
if(($non_anaest hetist_fee/100) > 0)
$fee .= "<option value = $non_anaestheti st>$non_anaesth etist</option>";
$fee .= "</select>"; [/PHP]

Ronald :cool:
Oct 8 '06 #6
assgar
41 New Member
Then test the values of the division:
[PHP]$fee = "<select name=\"fee[]\">";
if(($general_fe e/100) > 0)
$fee .= "<option value = $general>$gener al</option>";
if(($technical_ fee/100) > 0)
$fee .= "<option value = $technical>$tec hnical</option>";
if(($specialist _fee/100) > 0)
$fee .= "<option value = $specialist>$sp ecialist</option>";
if(($anaestheti st_fee/100) > 0)
$fee .= "<option value = $anaesthetist>$ anaesthetist</option>";
if(($non_anaest hetist_fee/100) > 0)
$fee .= "<option value = $non_anaestheti st>$non_anaesth etist</option>";
$fee .= "</select>"; [/PHP]

Ronald :cool:
Hi Ron
Thanks for the help.

It took you last suggestion to add the final piece of the puzzle.
I was also able to reduce the code by getting rid of the strlen().

Here is the final code.

while($row = mysql_fetch_arr ay($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_f ee= $row['anesthestist_f ee'];
$non_anaestheti st_fee= $row['non_anesthetis t_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_fe e/100);
$anaesthetist = sprintf("%9.2f" ,$anaesthetist_ fee/100);
$non_anaestheti st = sprintf("%9.2f" ,$non_anaesthet ist_fee/100);


/************dro p down*********** **/
//this is the dropdow box info put into an array for use use below

$fee = "<select name=\"fee[]\">

if($general > 0.00)
{
<option value = $general> $general</option>
}
if($technical > 0.00)
{
<option value = $technical> $technical</option>
}
if($specialist > 0.00)
{
<option value = $specialist> $specialist</option>
}
if($anaesthetis t > 0.00)
{
<option value = $anaesthetist> $anaesthetist</option>
}
if($non_anaesth etist > 0.00)
{
<option value = $non_anaestheti st> $non_anaestheti st</option>
}
</select>";
Oct 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10090
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list closes. The closing of the dropdown list can happen without changing the dropdown, hence the onchange event is not a sure way to determine that the dropdown list closed. Is this possible in Internet Explorer?
2
5450
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would like to eventually be able to filter down through the tables untill i can reach one unique record. I am creating a datbase to keep track of registered accounts for a stae program. Each account is registered into the program through a two...
1
5245
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including subreports, filters perfectly, with the exception of a running sum DLookup field on the main report. This field looks up a value in a foreign table. I'm not clear where I'm supposed to be filtering this field, since it obviously isn't picking up the...
1
1150
by: rk | last post by:
Hi, I need to provide filtering feature for the columns in datagrid. for that I need to provide a drop down arrow image/button in some columns and when that arrow button is clicked, it should display the dropdownlist/listbox with the distinct values for that column so that user can filter the rows using those column values. can anybody tell me how I can get the dropdown to look like an arrow image first and then expand underneath when...
2
2067
by: Gummy | last post by:
Hello All, I have a webpage that has two dropdown listboxes. Based on what is selected in these dropdown listboxes, it filters a DataGrid . That works fine. In the DataGrid , when I go to edit a row, I change the textbox (or other control), click Update, but it doesn't save my data. I then did this... In Page_Load, I added code to filter the DataGrid only when it was Not Page.IsPostBack. Then the editing/updating of the DataGrid data...
5
3438
Tann3r
by: Tann3r | last post by:
Apache.v2.2.4, MySQL.v5.0.27, PHP5.2.1 I have a table of projects which has been dynamically created from an SQL query. I have several dropdown boxes which have been populated from other tables within the database and i would like to filter the information shown in the main table dependant upon the items selected in the dropdown list(s). I assume that this needs to be done using java to enable the list to be refreshed as soon as a dropdown...
2
2609
by: Dev1 | last post by:
All- I'm new to this forum and i've been working with acces for about 2 days now. I have a form in which I have two combo boxes and depending on what is selected on the first dropdown the second one gets populated accordingly, which is great! There are two problems; First the when I select the value from the second drop down the value in the first and second combo box go away!! Second when I remove the filter the values for all the...
6
1989
by: topher83 | last post by:
Hi Im trying to create a form to search a hardware database for items, the form consists of two boxes, a dropdown box and a text box. The user needs to choose a field from the dropdown box and then enter the text the want to search for in the text box and the press search Its comming up results have been filtered however its not displaying them Can anyone see any problems with my code Thanks Private Sub cmdSearch_Click() If...
3
1807
by: flymo | last post by:
Hello All, I've bee trying out access 2007 and have a weird issue and would like to see if I'm issing something really basic. I have a form based on a query, I create a combo to look for records on my form based on Org_ID. Wgen I create all is fine - I type e, combo goes to e and starts filtering etc just like normal......I save the form, close the database and when I re-open the combo doesn't respond to any input - I can select a...
0
8485
marktang
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...
0
8403
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,...
0
8930
Oralloy
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...
0
8677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
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();...
0
4227
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...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1816
bsmnconsultancy
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.