I am trying to create a html table from two arrays that look like this:
These values are from a wholesaler (remote database):
$array1 = array(
'skucode001' => '0',
'skucode031' => '2',
'skucode011' => '1',
'skucode071' => '54'
);
These values are from my database:
$array2 = array(
'skucode001' => '22',
'skucode031' => '3',
'skucode011' => '5',
'skucode071' => '231'
);
The arrays have all the keys identical and are previously sorted in the same order. Only the values (stock) may differ.
I need to place all these values so that I can easily compare them and update my stock when they do.
The end result should be a table like this:
THEIR SKU | THEIR STOCK | MY SKU | MY STOCK
skucode001 0 skucode001 22
skucode031 2 skucode031 3
skucode011 1 skucode011 5
skucode071 54 skucode071 231
It would be great if I could highlight the rows that have different stock values (in yellow) and the ones that have stock 0 on their side, in red.
In the future I will probably remove my sku column, but for now is just to double check what is printed.
I'm too embarrassed to post my code because is a mess and the table is completely broken. It's beyond my skill unfortunately.. Any help will be very much appreciated..
I tried to attach recursively parts of the html code to a variable and then go forward step by step until I appended the whole table. Problem is having two variables with a foreach..
Thank you