Compare two arrays in mysql and php -
i have small loop of time in day.
$datum = $date_final; $itimestamp = mktime(8,0,0,1,1,2014); ($i = 1; $i < $den; $i++) { $vypis = $datum.' '.date('h:i:s', $itimestamp) . "\n<br />"; $itimestamp += $sekundy; echo $vypis; }
it echo this:
2014-06-02 10:00:00 2014-06-02 10:30:00 2014-06-02 11:00:00 2014-06-02 11:30:00 2014-06-02 12:00:00 2014-06-02 12:30:00 2014-06-02 13:00:00 2014-06-02 13:30:00 2014-06-02 14:00:00 2014-06-02 14:30:00 2014-06-02 15:00:00 2014-06-02 15:30:00 2014-06-02 16:00:00 2014-06-02 16:30:00 2014-06-02 17:00:00
i have second script - mysql query loop
$data = mysql_query ("select * evenement"); $zaznam = mysql_fetch_array ($data); while($zaznam = mysql_fetch_array ($data)) { echo $zaznam["start"]; }
it give me similar results :
2014-05-25 19:30:00 2014-05-28 13:30:00 2014-04-21 09:30:00 2014-05-20 11:00:00 2014-05-28 13:00:00 2014-04-27 00:00:00 2014-05-21 12:00:00 2014-05-22 11:30:00 2014-05-20 13:00:00 2014-05-22 11:30:00 2014-05-28 15:30:00 2014-05-28 13:00:00
im trying write script compare every single echo $vypis results in mysql query. after can put condition here - if not in mysql - echo "free" , if in mysql echo "....". think have use foreach maybe. need compare 1 result php loop results db, apply conditions , next 1 result, compare .....
have ideas guys ? need small here.
to compare php array value sql values below (i hope asking about)
for ($i = 1; $i < $den; $i++) { $vypis = $datum.' '.date('h:i:s', $itimestamp) . "\n<br />"; $itimestamp += $sekundy; $arr1[]=$vypis;//store php values in first array }
//and in php while($zaznam = mysql_fetch_array ($data)) { $arr2[] = $zaznam["start"];//store query values in second array }
//and use forloops foreach($arr1 $k=>$val) { if(in_array($val,$arr2)) { echo '...'; } else { echo 'free'; } }
Comments
Post a Comment