0

Pls help me with this...

//FINANCE.PHP
<form id="frmpay" name="frmpay" method="POST" action="finance_payment.php">
<input type="radio" name="seltour[]" value="<?php echo $tour_code; ?>">
<input type="submit" value="input" name="submit" />
</form>

once submitted..

//FINANCE_PAYMENT.PHP
if(isset($_POST['submit'])) {	 
	
for($i=0;$i<$numrow;$i++){
$code = [B]$_POST['seltour'][/B][$i];
$query = "SELECT tour_amount, tour_name  FROM `tbl_tour_profile` 
WHERE tour_code = '[B]$code[/B]'";

$result = mysql_query($query);
$requests = mysql_fetch_array($result);	
	
$tour_name =  $requests['tour_name'];
$budget =  $requests['tour_amount']; 
	
$query2 = "INSERT INTO`tbl_finance` 
(`or_num`, `stud_num`, `tour_id`, `tour_name`, 
`deposit`, `balance`, `teller_num`, `status`) 
VALUES ('$code', '$tour_name', '$deposit')";

$result2 = mysql_query($query2);
if($result2){
$message = "transaction successful!"; alert_msg($message);	
		}else{
		}
 }
}

The code runs like this...
user will select TOUR using the radio button, put in an array, then submit.
Then in finance_payment.php, the array will be use to select the specific tour.

I dont know if my code is right. Im having errors saying:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

pls help... thanks

Edited by rakwel10: n/a

4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by ko ko
0

I think instead of this line:
$query = "SELECT tour_amount, tour_name FROM `tbl_tour_profile`
WHERE tour_code = '$code'";

You should have:
$query = "SELECT tour_amount, tour_name FROM tbl_tour_profile
WHERE tour_code = '$code'";

No ' around the table name

0

Pls help me with this...

//FINANCE.PHP
<form id="frmpay" name="frmpay" method="POST" action="finance_payment.php">
<input type="radio" name="seltour[]" value="<?php echo $tour_code; ?>">
<input type="submit" value="input" name="submit" />
</form>

once submitted..

//FINANCE_PAYMENT.PHP
if(isset($_POST['submit'])) {	 
	
for($i=0;$i<$numrow;$i++){
$code = [B]$_POST['seltour'][/B][$i];
$query = "SELECT tour_amount, tour_name  FROM `tbl_tour_profile` 
WHERE tour_code = '[B]$code[/B]'";

$result = mysql_query($query);
$requests = mysql_fetch_array($result);	
	
$tour_name =  $requests['tour_name'];
$budget =  $requests['tour_amount']; 
	
$query2 = "INSERT INTO`tbl_finance` 
(`or_num`, `stud_num`, `tour_id`, `tour_name`, 
`deposit`, `balance`, `teller_num`, `status`) 
VALUES ('$code', '$tour_name', '$deposit')";

$result2 = mysql_query($query2);
if($result2){
$message = "transaction successful!"; alert_msg($message);	
		}else{
		}
 }
}

The code runs like this...
user will select TOUR using the radio button, put in an array, then submit.
Then in finance_payment.php, the array will be use to select the specific tour.

I dont know if my code is right. Im having errors saying:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\Main\finance_payment.php on line 14

pls help... thanks

Why are you using a form with only one radio button? And are you trying to turn it into an array? Because that isn't how you're supposed to do it.

As for your processing script, you're using a for loop that's calling a variable that doesn't exist. You're trying to force the POST variable to be an array. And your insert script has a 8:3 column to value ratio.

0

Thankyou for your replies

@magic media, I just didnt include the whole script. this is how I use the radio button:

<?php 

	$query3 = "SELECT * FROM `tbl_tour_profile`";	
	$result3 = mysql_query($query3);
	$num3 = mysql_num_rows($result3);
	while($tour = mysql_fetch_array($result3) ){
	
		$tour_code = $tour['tour_code'];
		$tour_name = $tour['tour_name'];
		$date = $tour['date'];
		$subj_code = $tour['subj_code'];
		$budget = $tour['tour_amount'];	

?>

<tr>
<td ><p><?php echo $tour_code; ?></p></td>
<td ><p><?php echo $tour_name; ?></p></td>
<td ><p><?php echo $date; ?></p></td>
<td ><p><?php echo $subj_code; ?></p></td>
<td ><p><?php echo $budget; ?></p></td>
<td ><input type="radio" name="seltour[]" value="<?php echo $tour_code; ?>"></td>
</tr>
<? }?>

@cgull, the sql came from myslq so I believe quotes in the table is not the problem.

0

Check $num3, by echoing or using var_dump($num3). If it has non-zero value (1,2,3,...), the query is ok. Otherwise, check you've table named 'tbl_tour_profile', and ensure that the table name also corrected.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.