I have a code in Javascript that looks like this.
for (var i in data){
var trans_no = data[i]; //getting e row from table
var transno = trans_no.transno
var transdate = trans_no.transdate
var dropno = trans_no.drop
var cusname = trans_no.customername
var shipto = trans_no.shipto
var active = trans_no.active
alert(transno + transdate + dropno + cusname + shipto + active);
// window.location.href = "main.php?transno=" + transno;
}
What happens on that code is when I press a button my data from a source file is grabed and put it on the declarations above then display it in my alert or msgbox
and here is my php code on how to save data in SQL
<?php
include('config.php');
include('adodb/adodb.inc.php');
$db = ADONewConnection($dbdriver);
$db->Connect($dsn, $username, $password);
$sqlSync = "My SQL Query";
$rsSync = $db->Execute($sqlSync);
?>
now lets say that my columns in my table is same name as inside in the alert(). My question is that the script is encased in a loop. How can I save the data in SQL for every loop? I mean save the data that the loop made. TYSM
store your data into an array then after loop completed, use AJAX
call to pass the data to php
for saving data.
Then with array you can insert multiple data with same query.
INSERT INTO tbl_name
(a,b,c)
VALUES
('a','b','c'),
('x','y','z'),
('q','w','e');