<?php
include "includes/db_connect.php";
include "mobex_send.php";

$q = $conn->query("
    SELECT * FROM transactions
    WHERE status='QUEUED'
    AND retry_count < 3
");

while ($tx = $q->fetch_assoc()) {

    $res = sendToMobexADR($tx);

    $conn->query("
        UPDATE transactions
        SET last_attempt=NOW(),
            retry_count=retry_count+1
        WHERE id={$tx['id']}
    ");
}
