How to make a mysql statement for sent log
In next iteration, you may need to check if there are pending numbers to send sms. If pending count is greater than zero then need to send sms to those pending numbers.

track success_count after resending sms to pending numbers.

Then, need to increment delivered count and decrement pending count with this success_count.

So, 

delivered  = delivered + success_count
pending = pending - success_count


then you may need to execute update on make_sent_log table with this updated delivered and pending counts.

update `make_sent_log` set delivered = delivered, pending = pending where transaction_id = 'trans_1';


Continue this iteration cycle until pending count = zero.