473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically created form info not passing all data properly

41 New Member
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
Oct 23 '06 #1
4 2699
ronverdonk
4,258 Recognized Expert Specialist
You already had 8 posts in this forum so you must know that you have to enclose code within [php] or [code] tags. And if you don't it is time you read the Posting Guidelines at the top of this forum.!!

I will not read your code in this state!

Ronald :cool:
Oct 23 '06 #2
assgar
41 New Member
You already had 8 posts in this forum so you must know that you have to enclose code within php or code tags. And if you don't it is time you read the Posting Guidelines at the top of this forum.!!

I will not read your code in this state!

Ronald :cool:
Hello Ron

Regarding the posting guide lines

I have read the posting guide lines it could be that our interpretations of those guide lines differ so let go through it. the only things that I see that do not have tags are the headings of the sections.

Your assistance would be appreciated. Please point out where I have not followed the posting guide lines. It would be helpful so I understand more clearly what you are saying. My approach coding may be different. This is the actual code except the form but that could be why I may be having problems.

1) Relevant forum : this is the PHP forum and my question is PHP related.
2) Clear title: "dynamically created form info not passing all data properly"
to me this clearly describe the porblem.
3) Details: I use 3 scripts(form, function and process).
Development on win2003 server. Final server will be linux
Apache,Mysql and PHP is being used.
There are no error messages to report.

4) Concise:
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

5)use html and php tags:
Note: I add titles to indicate what the different scripts are

This is script number 1
the_Form.php

[php]
<?php <========================== php tag
include("../display_function.php");//display to display dynamic rows

?> <========================== php tag


<html> <========================== html tag

<!-----------------------form processor---------------------------->
<form action="../process.php" method="post">

<table><========================== html tag

<!------------------------search button------------------------------------>
<tr><========================== html tag

<td width="99%"><input type="submit" name="fee_button" value="Search" />
</td><========================== html tag

</tr><========================== html tag

<? <========================== php tag

echo display($services);//this function display dynamic rows
?><========================== php tag

</table><========================== html tag
</html><========================== html tag
[/php]
This is script number 2
display_function.php
this function is placed in the form

[php]
<?php <============================php tag
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 tag
[/php]
This is script number 3
display results

[php]
<?php <==========================php tag
/****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 tag
[/php]
Edited the code within php tags - Ronald
Oct 24 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
assgar, you overlooked 1 point in the posting guidelines and that is the request to
For code, use the tag buttons at the top of the edit area:
- Use [PHP] and [ /PHP] tags around your PHP code
- Use [HTML] and [ /HTML] tags around your HTML code
- Use [code] and [ /CODE] tags around other code
Included code is very difficult and hard to read when members do not post it within the mentioned tags. These tags are at the top of the message area and are indicated by either a pound sign #, html tags sign (< >) or the php sign (page with php), you can't miss them. Especially when mebers always seem to be able to find the quote tags.

As for myself, when I see a flood of unformatted code coming by, my first inclination is to skip that thread, because its code is absolutely unreadable from a screen. I know more members think like that, so it is in the requestor's own interest to present the code in a pleasantly readable format. That is the reason that we urge people to use these tags.

I hope this explains my complaint. Happy coding!

Ronald :cool:
Oct 24 '06 #4
assgar
41 New Member
Hi Ron

I have reposted my question (cry for help) using your explanation.

I am stuck on a problem.

I use 3 scripts(form, function and process).
Developemnt 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

This is the form t_Form.php
[PHP]
<?php
include("../display_function.php");//display to display dynamic rows
?>
[/PHP]

[HTML]
<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>
[PHP]
<?
echo display($services);//this function display dynamic rows
?>
[/PHP]
</table>
</html>

[/HTML]

This is the function display_function.php
[PHP]
<?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]

This is the process t_process.php
[PHP]
<?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]
Oct 24 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
4298
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
1
1022
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
2
4533
by: D Hass | last post by:
Radio Buttons are added to my form During the Load event, the quantity determined by User input. They are placed in pairs on groupboxes with code like this: (edited a bit for brevity) Public...
4
1886
by: Stone Chen | last post by:
Hello, I have form that uses javascript createElement to add additional input fields to it. However, my validating script will not process new input fields because it can only find the named...
12
3151
by: Steve_Black | last post by:
I posted a similar message earlier but we've geared away from the original topic somewhat so I thought I'd post again in hopes of getting input from others. I am creating a MenuStrip...
1
2252
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function ////////////////////////////////////////////////////////////////////////////////////...
2
6510
by: ssmith147 | last post by:
Hi, I'm somewhat familiar with access and vb programming (I can read someone else's code, for the most part), but I'm still very green when it comes to creating solutions for my own needs. I'm...
4
5913
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
2
2460
by: Austin326 | last post by:
Hi Everyone, I have a problem that is quite frusturating. I am passing in an image from a database, which is to be accessed in an image button. When I dynamically add the string for an sql...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
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...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5085
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...
0
4745
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...
0
3232
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...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.