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 post
Share on other sites
  • 5 weeks later...
  • 2 weeks later...

i solved it bro thank you here is the code 

<?php
			if(isset($_POST['submit'])){
				// 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 
				$q=rtrim($q,",");
				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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...