hi all,
I need to fill the dates that are missing in a mysql table.
eg:
If a month is 31 days, must know the dates that are missing in the month.
I thought of making a comparison using arrays, which seems to be the right way, but for some reason I'm not able to do it.
maybe something like this
for ($ a = 1; $ a <date (j), $ a) (
if (strlen ($ a) =='1 ') ($ a = "0 $ to"
)
which generates 01 to the date of the current day (today).
in other words, must compare two strings and show what is missing.
like,
array1 = array ( 'a' => 1,2,3,4);
array2 = array ( 'b' => 1,3,4);
using the code:
? php
$ array1 = array ( 'a' =>'1 ', 2','3 ','4');
$ array2 = array ( 'a' =>'1 ','3','4);
$ difference = array_diff ($ array1, $ array2);
foreach ($ difference as $ k => $ v) (
echo "$ difference [$ k] <br />";
)
result will be 2, which is missing in array2
?>
in other words, must get across the table column (date) put in (array1)
generate a code dates of 01 until the present day and put in the (array2)
for ($ a = 1; $ a <date (j), $ a) (
if (strlen ($ a) =='1 ') ($ a = "0 $ to"
$ d = date ( "Y-m-$ to");
$ s = '$ d', ";
$ array2 = array ( 'b' => $ s);
)
and compare the two arrays, which shows what dates are missing, then I used the mysql insert to fill out the dates that are missing.
I think it is just that. It should be a simple thing to do for those who knows.