So I have a mysql table for the charges of a hospital. My program currently only gets the price of the checked procedure. But now, I also want to get the procedure name when it is checked.
transaction.php
computation.php
I made a new parameter so I pass another value. The price works. It computes. The procedure name doesnt. It outputs the word "Array".
transaction.php
while($row = mysql_fetch_array($result)){ echo ' <tr> <td>'.$row[0].'</td> <td>'.$row[1].'</td> <td>'.$row[2].'</td>'; $price=$row['price']; $procedure=$row['procedure']; echo '<td><input type="checkbox" name="er[]" value="'.$price.'">'; echo '<input type="hidden" name="procedures[]" value="'.$procedure.'"></td>'; echo "</tr>"; } echo '</table>';
computation.php
<?php if(isset($_POST['er'])){ $ercharge=$_POST['er']; $totalofer = array_sum($ercharge); $procedure = $_POST['procedures']; } if(isset($_POST['ultrasound'])){ $x=$_POST['ultrasound']; $totalofultrasound = array_sum($x); } if(isset($_POST['confinement'])){ $y=$_POST['confinement']; $totalofconfinement = array_sum($y); } //$total = $totalofer + $totalofultrasound + $totalofconfinement; foreach($procedure as $val) { echo "Procedure:". $val. "<br>"; } echo "Total: ".$totalofer; ?>
I made a new parameter so I pass another value. The price works. It computes. The procedure name doesnt. It outputs the word "Array".