khan.sikki Posted July 20, 2019 Share Posted July 20, 2019 (edited) 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 July 20, 2019 by khan.sikki Link to comment Share on other sites More sharing options...
justsomeguy Posted July 22, 2019 Share Posted July 22, 2019 What happens when you run that? What exactly are you having problems with? Link to comment Share on other sites More sharing options...
khan.sikki Posted August 21, 2019 Author Share Posted August 21, 2019 what i am asking is a inserting multiple values of looped table, above is is just inserting the last value of looped table Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2019 Share Posted August 21, 2019 There's not enough code there to suggest much. What does the form look like? What data is sent in $_POST? Link to comment Share on other sites More sharing options...
khan.sikki Posted September 2, 2019 Author Share Posted September 2, 2019 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 comment Share on other sites More sharing options...
justsomeguy Posted September 3, 2019 Share Posted September 3, 2019 There's not enough information to help you. You have a for loop there where you keep inserting the same thing, but I don't know what data is being submitted to the page. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now