Jump to content

Inserting fetched multiple rows into table


Recommended Posts

Hello I am Sikandar 

need assistance in inserting multiple data  which was fetched from a recordset in a table

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_trips")) {
  $insertSQL = sprintf("INSERT INTO trips (trip_date, trip_no, hab_id) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['trip_date'], "date"),
                       GetSQLValueString($_POST['trip_no'], "int"),
                       GetSQLValueString($_POST['hab_id'], "int"));

  mysql_select_db($database_conn_db, $conn_db);
  $Result1 = mysql_query($insertSQL, $conn_db) or die(mysql_error());

  $insertGoTo = "u_home.php?trip=t";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $insertGoTo));


Edited by khan.sikki
Link to comment
Share on other sites

  • 5 weeks later...
  • 2 weeks later...

i solved it bro thank you here is the code 

				// insert attendence to database
				$q= "INSERT INTO attendence(date,school_id,class,period,teacher,student_id,status) VALUES";
				//creating arrary to receview multiple rows values
				for ($a=1;$a<=$totalRows_students;$a++){
					//assigning multiple values to inset into values
					$q .="('".$_GET['date']."','".$_GET['school']."','".$_GET['class']."','".$_POST['period']."','".$_POST['teacher']."','".$_POST['student_id'][$a]."','".$_POST['status'][$a]."'),";
				//removing "," from statement 
				mysql_select_db($database_localhost, $localhost);
				mysql_query($q, $localhost) or die(mysql_error());
				// displaying result
				echo '<p align ="center"class="alert">'.strtoupper($row_teachers['name']).' గారు మీరు వేసిన హాజరు జతచేతయబడినది ఫోటో జియోట్యగ్ ప్రక్రియను పూర్తి చేయండి</p>';


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...