function format_all_clinics_as_4table($where = "", $order = "start_date, end_date") { global $opts, $event_tools_db_prefix, $event_tools_href_add_on; mysql_connect($opts['hn'], $opts['un'], $opts['pw']); @mysql_select_db($opts['db']) or die("Unable to select database"); if ($where != NONE) { $where = " WHERE " . $where; } $query = "\r\n SELECT *\r\n FROM " . $event_tools_db_prefix . "eventtools_clinics_with_tags\r\n " . $where . "\r\n ORDER BY start_date, end_date, name\r\n ;\r\n "; //echo $query; $result = mysql_query($query); $i = 0; $num = mysql_numrows($result); //echo "num: ".$num."<br/>\n"; if ($num == 0) { mysql_close(); return; } $lastmajorkey = mysql_result($result, 0, "id"); echo "<table border=\"1\" class=\"et-clinic\">\n"; while ($i < $num) { if ($lastmajorkey != mysql_result($result, $i, "id")) { $lastmajorkey = mysql_result($result, $i, "id"); echo "</table>\n"; echo "\n"; echo "<table border=\"1\" class=\"et-clinic\">\n"; } echo "<tr class=\"et-clinic-tr1\">\n"; echo " <td class=\"et-clinic-td1\">\n"; echo " <a name=\"" . mysql_result($result, $i, "id") . "\"></a>\n"; echo " <span class=\"et-clinic-name\">" . htmlspecialchars(mysql_result($result, $i, "name")) . "</span>\n"; echo " </td>\n"; echo " <td class=\"et-clinic-td2\">\n"; echo " <span class=\"et-clinic-date\">" . daydate_from_long_format(mysql_result($result, $i, "start_date")) . "</span>\n"; echo " </td>\n"; echo " <td class=\"et-clinic-td3\">\n"; echo " <span class=\"et-clinic-start\">" . time_from_long_format(mysql_result($result, $i, "start_date")) . "</span>\n"; echo " </td>\n"; echo " <td class=\"et-clinic-td4\">\n"; echo " <span class=\"et-clinic-end\">" . time_from_long_format(mysql_result($result, $i, "end_date")) . "</span>\n"; echo " </td>\n"; echo "</tr>\n"; if (mysql_result($result, $i, "clinic_presenter") != '') { $clinic_presenter = htmlspecialchars(mysql_result($result, $i, "clinic_presenter")); } else { $clinic_presenter = "(no presenter name provided)"; } if (mysql_result($result, $i, "description") != '') { $description = mysql_result($result, $i, "description"); } else { $description = "(no description provided)"; } echo "<tr class=\"et-clinic-tr2\">\n"; echo " <td colspan=\"3\" class=\"et-clinic-td1\">\n"; echo " <span class=\"et-clinic-presenter\">" . $clinic_presenter . "</span>\n"; echo " </td>\n"; echo " <td class=\"et-clinic-td2\">\n"; echo " <span class=\"et-clinic-location\">" . htmlspecialchars(mysql_result($result, $i, "location_name")) . "</span>\n"; echo " </td>\n"; echo "</tr>\n"; echo "<tr class=\"et-clinic-tr3\">\n"; echo " <td colspan=\"4\" class=\"et-clinic-td1\">\n"; echo " <div class=\"et-clinic-description\">" . $description . "</div>\n"; echo " </td>\n"; echo "</tr>\n"; echo "<tr class=\"et-clinic-tr4\">\n"; echo " <td colspan=\"4\" class=\"et-clinic-td1\">\n"; if (mysql_result($result, $i, "clinic_url") != '') { echo " <span class=\"et-clinic-url\"><a " . $event_tools_href_add_on . " href=\"" . mysql_result($result, $i, "clinic_url") . "\">" . mysql_result($result, $i, "clinic_url") . "</a></span>\n"; } echo " </td>\n"; echo "</tr>\n"; // process tags echo "<tr class=\"et-clinic-tr5\">\n"; echo " <td colspan=\"4\" class=\"et-clinic-td1\"><span class=\"et-clinic-tags\">\n"; echo htmlspecialchars(mysql_result($result, $i, "tag_name")); while ($i < $num - 1 && mysql_result($result, $i, "id") == mysql_result($result, $i + 1, "id")) { $i++; echo ",\n" . htmlspecialchars(mysql_result($result, $i, "tag_name")); } echo "\n </span></td>\n"; echo "</tr>\n"; // spare line at end echo "<tr class=\"et-clinic-tr6\">\n"; // blank line echo " <td colspan=\"4\" class=\"et-clinic-td1\">\n"; echo " </td>\n"; echo "</tr>\n"; $i++; } // done, clean up echo "</table>\n"; mysql_close(); }
function format_misc_events_by_loc($url = NONE, $where = NONE) { global $opts, $event_tools_db_prefix; mysql_connect($opts['hn'], $opts['un'], $opts['pw']); @mysql_select_db($opts['db']) or die("Unable to select database"); $dates = array("2011-07-01", "2011-07-02", "2011-07-03", "2011-07-04", "2011-07-05", "2011-07-06", "2011-07-07", "2011-07-08", "2011-07-09", "2011-07-10"); $k = 0; if ($where != NONE) { $where = " AND " . $where . " "; } else { $where = ""; } while ($k < count($dates)) { // query for start times $query = "\r\n SELECT DISTINCT start_date\r\n FROM " . $event_tools_db_prefix . "eventtools_misc_events_with_tags\r\n WHERE start_date LIKE '" . $dates[$k] . "%'\r\n " . $where . "\r\n ORDER BY start_date\r\n ;\r\n "; //echo $query; $result = mysql_query($query); $i = 0; $num = mysql_numrows($result); if ($num == 0) { $k++; continue; } // fixed time slots regardless $starttimes = array("08:00", "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "19:00", "19:30", "20:00", "20:30", "21:00", "21:30", "22:00", "22:30"); // add dynamic entries while ($i < $num) { $starttimes[$i] = substr(mysql_result($result, $i, "start_date"), -8, 5); $i++; } // remove duplicates sort($starttimes, SORT_STRING); $starttimes = array_values(array_unique($starttimes)); // now query for misc events $query = "\r\n SELECT *\r\n FROM " . $event_tools_db_prefix . "eventtools_misc_events_with_tags\r\n WHERE start_date LIKE '" . $dates[$k] . "%'\r\n " . $where . "\r\n ORDER BY location_name, start_date, name, tag_name\r\n ;\r\n "; $result = mysql_query($query); $i = 0; $num = mysql_numrows($result); if ($num == 0) { $k++; continue; } $lastmajorkey = ""; echo "<h2 class=\"et-mebl-h2\" >" . daydate_from_long_format($dates[$k]) . "</h2>\n"; echo "<table border=\"1\" class=\"et-mebl-table\">\n"; $j = 0; // header row echo "<tr class=\"et-mebl-tr-head\"><th class=\"et-mebl-th-corner\">Location</th>"; while ($j < count($starttimes)) { echo "<th class=\"et-mebl-th-time\">" . $starttimes[$j++] . "</th>"; } echo "</tr>\n"; $k++; // loop over locations, using SQL query order while ($i < $num) { // search for new location if ($lastmajorkey != mysql_result($result, $i, "location_name")) { $lastmajorkey = mysql_result($result, $i, "location_name"); // gather the elements for this location, this date $rowindexes = array(); while ($i < $num) { if ($lastmajorkey == mysql_result($result, $i, "location_name")) { $rowindexes[] = $i; // skip dups due to tags while ($i < $num - 1 && mysql_result($result, $i, "name") == mysql_result($result, $i + 1, "name") && mysql_result($result, $i, "start_date") == mysql_result($result, $i + 1, "start_date")) { $i++; } $i++; } else { break; } } output_misc_location($result, $rowindexes, $starttimes, $num, $url); } else { echo "\nerror lining up at i=" . $i . "\n"; } } // end of loop over locations // done, clean up echo "</tr>\n"; echo "</table>\n"; } mysql_close(); }