Hi,
Tried so much combinations with this issue, that my eyes are pulling out....
So, i like to check, if there is match for some values in table against uploaded text-file. Actually checking if customer was paid his invoices.
This code below is working generally, but mark only first row what match. Not continuing to next row.
Yes, preg_match and stripos works like so, and stops to first match. I tried some foreach-functions, but after results didn't got the working resolution. Just got echoed values, without getting them inside update query.
Need for some help with this. If you have some good proposals for get this working.
Here is the code, what should be fixed to correct way:
if(isset($_POST['scrstr'])) {
$scrstr=$_POST['scrstr'];
$file=file_get_contents('upload/'.$scrstr.'');
$filename='upload/'.$scrstr.'';
$fetch = mysqli_query($db,"SELECT * FROM $invoicingtable WHERE paid<>'1'");
while($row = mysqli_fetch_array($fetch)) {
$id=$row['id'];
$invoicenr=$row['invoicenr'];
$custname=$row['custname'];
$custname = preg_replace('/\s+/', '', $custname);
$totalsum=$row['totalsum'];
$totalsum = preg_replace('/\./', '', $totalsum);
if(preg_match('/'.$invoicenr.'/', $file)) { $val1res=1; $updfoundinv = mysqli_query($db,"UPDATE $invoicingtable SET paidstat='$filename' WHERE id='$id'"); }
if(preg_match('/'.$custname.'/', $file)) { $val2res=1; }
if(preg_match('/'.$totalsum.'/', $file)) { $val3res=1; }
if($val1res==1 AND $val2res==1 AND $val3res==1) { $updpaidstat = mysqli_query($db,"UPDATE $invoicingtable SET paid='1', paidstat='$filename' WHERE id='$id'"); }
header('Location:invoicedopen.php');
mysqli_close($db); } }