Hi
I am stuck on a problem.
I use 3 scripts(form, function and process).
Development on win2003 server. Final server will be linux
Apache,Mysql and PHP is being used.
The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply.
Note The above informaton is coming from a mysql database.
When the service is submitted the selected information is displayed to the secreen by the process.
Here is my problem.
If I select the first row in the dynamically created rows the correct code_id, units and fee is passes to be process and displayed.
If I select the second or any other row in the dynamically created rows the correct code_id only is passed. No units and fee is passes to be processed and displayed
If I select the first row and any other dynamically created rows the correct code_ids, units and fees are passes to be processed and inserted.
If I select any other two or more rows in the dynamically created rows the correct code_id only is passed for the first row in the group, no units and fee. But the subsequence rows will have the code_id, units and fees passed to be processed and inserted.
Have you ever encountered this problem? Any suggestions what it could be?
How do I make this work so the user can select anything they want and have it displayed?
If you could respond quickly it would be great.
Thanks in advance
[php]
/****the_Form.php****/
<?php
include("../display_function.php");//display to display dynamic rows
?>
<html>
<!-----------------------form processor---------------------------->
<form action="../process.php" method="post">
<table>
<!------------------------search button------------------------------------>
<tr>
<td width="99%"><input type="submit" name="fee_button" value="Search" />
</td>
</tr>
<?
echo display($services);//this function display dynamic rows
?>
</table>
</html>
/****display_function.php****/
//this function is placed in the form
<?php
function display($services)
{
$data = "SELECT c.code_id, c.fee_code, c.description, m.general_fee,
m.technical_fee, m.specialist_fee, m.anaesthetist_fee,
m.non_anaesthetist_fee
FROM bill_ohip_fee_code c, $fee_master_table m
WHERE c.fee_code = m.code
AND c.section_code = '$services'
AND premium != 'Y'
ORDER BY c.fee_code";
$result = mysqli_query($mysqli,$data);
while($row = mysqli_fetch_array($result))
{
$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['anaesthetist_fee'];
$non_anaesthetist_fee= $row['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 = sprintf("%9.2f",$non_anaesthetist_fee/100);
//dropdown list of fees that filter out 0.00
$fee = "<select name=\"fee_select[]\">";
$fee .= "<option value = > Select</option>";
if($general > 0.00)
$fee .= "<option value = $general>Gen: $general</option>";
if($technical > 0.00)
$fee .= "<option value = $technical>Tec: $technical</option>";
if($specialist > 0.00)
$fee .= "<option value = $specialist>Spe:
$specialist</option>";
if($anaesthetist > 0.00)
$fee .= "<option value = $anaesthetist>Ana:
$anaesthetist</option>";
if($non_anaesthetist > 0.00)
$fee .= "<option value = $non_anaesthetist>Non:
$non_anaesthetist</option>";
//input box is displayed if no fee values for all 5
elseif($general == 0.00 && $technical == 0.00 && $specialist ==
0.00 && $anaesthetist == 0.00 && $non_anaesthetist == 0.00)
$fee .= "<input type=\"text\" name=\"fee_select[]\" size=\"9\"
maxlength=\"7\" value =\"$ohip_fee\"/>\n";
$fee .= "</select>";
//diaplay search results in rows
echo"<tr height=\"10\">
<td width=\"4%\" align=\"center\">
<input type=\"checkbox\" name=\"fee1_choice[]\"
value=\"$code_id\"></td>
<td width=\"7%\" ><span class=\"style20
\"><strong>$fee_code</strong></span></td>
<td width=\"3%\" height=\"10\">
<input type=\"text\" name=\"fee1_unit[]\" size=\"1\"
maxlength=\"2\" value =\"$fee_unit\"/>
</td>
<td width=\"79%\" class=\"style20\"> $description </td>
<td width=\"6%\" align=\"left\"> $fee </td>\n";
echo"</tr>\n";
}//end of while
//return array from function
return $all_array = array(fee1_choice, fee1_unit, fee1_money);
}
//unpack returned array
list($fee1_choice, $fee1_unit, $fee1_money)= $all_array;
}//end function
?>
<?php
/****process.php****/
/*** arrays passed from the form with selected variables ***/
$code_id = ($_POST['fee1_choice']); //array of code_id primary key
$fee1_unit = ($_POST['fee1_unit']);//array with the number of units
$fee1_money = ($_POST['fee1_money']);//array selected fee
//loop through array to get values
for($row = 0; $row < count($code_id); $row++)
{
echo "first".$code_id[$row].", ".$fee1_unit[$row].", ".$fee1_money
[$row];
echo "<br/>";
}
?>
[/php]
Edited the code and put within php code tags. - ronverdonk