1 Replies - 1272 Views - Last Post: 17 March 2013 - 07:04 AM Rate Topic: -----

#1 xuany  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 03-March 10

how to add record one after another ?

Posted 17 March 2013 - 06:51 AM

Dear all,

i would like to insert a record, then after inserting the record, it show in the table, then i can add another record. Just like what we fill in a form about our Academic qualification.
first we fill in the diploma level, then we add another record of degree level, then postgraduate level and then PHD level.

my code is as below, but it only insert one row, how do i continue with second row and so on.
<?php
include "connection.php";  // include this php file to connect the form with the db.
//$getId=$_GET["id"];
$getId=mysql_real_escape_string($_GET['id']);
//ambil input dpd user
// $_POST[]; -- to capture the txt keyed in by user
		
		$date=mysql_real_escape_string($_POST["date1"]);
		$type_fees=mysql_real_escape_string($_POST["lstfees"]);
		$amount=mysql_real_escape_string($_POST["txtamount"]);
		$receipt=mysql_real_escape_string($_POST["txtreceipt"]);
					
		
		$sql = "INSERT into payment(id,date,type_fees,amount,receipt,membership)";
		
		$sql.="VALUES('','$date','$type_fees','$amount','$receipt','$getId')"; 
		
 	
	 $result=mysql_query($sql) or die(mysql_error()); 
	 echo "Record saved";
	 echo "<br /> <META HTTP-EQUIV = 'Refresh' Content = '2; URL =search_member.php'>";	
//header("location:register_payment.php?id=$row[id]");
?>
        </p>
          
       
    </div>
      <!-- end .content -->
</body>
</html>


thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: how to add record one after another ?

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2983
  • Posts: 10,313
  • Joined: 08-August 08

Re: how to add record one after another ?

Posted 17 March 2013 - 07:04 AM

First, learn to use prepared statements. Here's a great PDO tutorial.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1