I have an excel file that I'm stripping down in AIR and converting to $ delimited string. I send that string to PHP ($pushFinal
) and then use $array = explode("$",$pushFinal);
to convert the string to an array. Now I want to loop through the array, inserting the values into SQL, mimicking the excel format. Each 'line' in excel is 49 columns, or 'values' so I need to insert 49 values at a time from the $array
for each row in SQL.
What is the best way to do this?
I'm a rookie so have mercy on me :)
So, I tried this:
$pushFinal = $_POST["pushFinal"];
$lines = array();
$lines = explode("|",$pushFinal);
$lineItems = array();
foreach ($lines as $val){
$lineItems = explode("$",$val);
$temp = "";
foreach($lineItems as $val2){
$temp = $temp."'".$val2."',";
}
$sql="insert into OPS_SCHEDULE values($temp)";
$stmt = sqlsrv_query($conn,$sql);
}
The INSERT is failing though. Does this look right? I delimited each line from excel with | and then delimited each value in that line by $. That shows up correctly in $pushFinal.