Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Getting two values from one checkbox form

$
0
0
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

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".

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>