Tuesday, 15 May 2012

php - I need to pass three values with a dropdown -


On my website I have a dropdown for different units of measurement. A person can fill their dose, then select one unit Can do the form and then submit the form. I also have the conversion field in the table of my units

  units ID. Unit Conversion1 G. 1000   

I want to give the conversion value associated with the selected dropbox field, so that in my controllers, before I save, I can multiply my 'DOS' conversion value. The problem is that I do not know how to actually get conversion value. I think try to run () to select the value matching the unit ID (), but it seems that my search is not returning any results. It looks like $ this-> Unit- & gt; Search ('first', array ('conditions' => (array' = unit '=>> $ this- & gt; Request- & gt; data [' RecordDrugUnit '] [' unit_id ']),' field '= & Gt; array (' conversion ')));

I then

  $ this-> Request-> Data ['RecordDrugUnit'] ['quantity'] = (int) $$ - & gt; Request-> Data ['RecordDrugUnit'] ['Quantity'] * (integer) $ this-> Request-> Data ['unit'] ['conversion'];   

got it

  $ conv_val = $ this- & gt; Unit- & gt; Search ('first' ('first' ('conversion' = & gt; array ('id' =>> $ this- & gt; request- & gt; data ['RecordDrugUnit'] ['unit_id']), 'field' = & Gt; array ('conversion'))); $ [This- & gt; Request-> Data ['RecordDrugUnit'] ['dos'] = (int) $ this- & gt; Request-> Data ['RecordDrugUnit'] ['dos'] * (int) $ conv_val ['unit conversion'];    

This conversion is better in php.

Units dropdown from your DB table: Table_ID serial, unit CRAR (5), conversion (flot) you can do this:

  $ u = mysqli_real_escape_string ( $ Mysqlidb, $ _ POST ['unit']) Identify WHERE unit = '$ u'; I do not really recommend that you do it in this way, though this mechanism is used for medical purposes. You should use an approved database in which the name of the drug, dosage and otherwise associated errors are otherwise fixed.  

There are many suitable DBS available, or you can always make your own.

No comments:

Post a Comment