Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd an event in a calendar
    text
    copied!<p>I solved a few months ago the problem of getting data from two tables and make an event calendar. You can see here:<a href="https://stackoverflow.com/questions/17670227/get-data-from-two-tables-to-make-an-event-calendar">original question</a>. Now I want something more: I want to ad an event for EVERY users in the same time. Let's say is a holiday (like Christmas) and I want to add this event for all users. I am using two queries first is to select the holidays and second to select if user was present. If present tip_id = 0, if not tip_id = 1. Than I put everything in a table. If the day is Saturday or Sunday the color is grey (using css1), if user is present the cell color is white and if user is absent the color is red. What I need? If I have Holidays in that month, I need the cell color to be also grey (as Saturday and Sunday). I tried different ideas but or I was able to get grey ONLY the first Holiday day, or ONLY the last or I got error when there are NO holidays in that month. The code (extracted only the part where I need help) is like this:</p> <pre><code>$db_luna=11; $db_an=2013; $days_in_month = 31; mysql_select_db($database_dbconfig, $dbconfig); $query_Holidays = "SELECT substring(data,9,2) AS zile_sarbatoare, data FROM sarbatori WHERE sarbatori.`data` LIKE '".$db_an."-".$db_luna."-%' ORDER BY zile_sarbatoare"; $Holidays = mysql_query($query_Holidays, $dbconfig) or die(mysql_error()); $row_Holidays = mysql_fetch_assoc($Holidays); $totalRows_Holidays = mysql_num_rows($Holidays); mysql_select_db($database_dbconfig, $dbconfig); $query_Presence = "SELECT c.full_name, c.id_personal, COALESCE(MIN(CASE WHEN CONCAT($db_an, '-', $db_luna, '-01') BETWEEN start_date AND end_date THEN tip_id END),0) '1', COALESCE(MIN(CASE WHEN CONCAT($db_an, '-', $db_luna, '-02') BETWEEN start_date AND end_date THEN tip_id END),0) '2', COALESCE(MIN(CASE WHEN CONCAT($db_an, '-', $db_luna, '-03') BETWEEN start_date AND end_date THEN tip_id END),0) '3', COALESCE(MIN(CASE WHEN CONCAT($db_an, '-', $db_luna, '-04') BETWEEN start_date AND end_date THEN tip_id END),0) '4', COALESCE(MIN(CASE WHEN CONCAT($db_an, '-', $db_luna, '-05') BETWEEN start_date AND end_date THEN tip_id END),0) '5' FROM calendar c"; $Presence = mysql_query($query_Presence, $dbconfig) or die(mysql_error()); $row_Presence = mysql_fetch_assoc($Presence); $totalRows_Presence = mysql_num_rows($Presence);} &lt;?php do { ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $nr_crt, '. ' , $row_Presence['full_name']; ?&gt;&lt;/td&gt; &lt;?php $css1 = 'white'; $trim = ''; for ($a = 1; $a &lt;= $days_in_month; $a++){ $data_calculata = date("Y-m-d",mktime(0,0,0, $db_luna, $b, $db_an )); if ($row_Presence[$a] == 0) {$legend = $row_Presence['full_name']."".$a; $day_of_week = date("N",mktime(0,0,0, $db_luna,$a ,$db_an)); if ($day_of_week == 6 OR $day_of_week == 7) {$css1 = 'grey';} else {$css1 = 'white';} if ($row_Presence[$a] == 1) {$css1 = 'red'; $legend = $row_Presence['full_name']." - Absent";} echo '&lt;td " title= "'.htmlspecialchars($legend).'" class='.$css1.'&gt;&lt;/td&gt;'; $nr_crt = $nr_crt + 1; ?&gt; &lt;/tr&gt; &lt;?php } while ($row_Presence = mysql_fetch_assoc($Presence)); ?&gt; &lt;/table&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload