我看上了本表所花时间,然后将这些时间从这三个阵列中删除。 阵列为1-24时。
这一文字的最终目的是比较这些阵列中的所有失踪时间,使一大阵容与只有可用时间。
渔获量是,如果连续三度缺失时间,就需要加以检查。 如果是的话,这一时间不会出现在最后的阵列中。
例如:
<?php
include db-connect.php ;
if (isset($_GET[ month ]) && isset($_GET[ day ]) && isset($_GET[ year ])) {
$month = $_GET[ month ];
$day = $_GET[ day ];
$year = $_GET[ year ];
//string together date
$date = $month."/".$day."/".$year;
//define the queries
$sql1 = mysql_query("SELECT start_time, server FROM classes WHERE date = $date AND server = 1 ");
$sql2 = mysql_query("SELECT start_time, server FROM classes WHERE date = $date AND server = 2 ");
$sql3 = mysql_query("SELECT start_time, server FROM classes WHERE date = $date AND server = 3 ");
//define time lists for each server
$timelist1 = range(1, 24);
$timelist2 = range(1, 24);
$timelist3 = range(1, 24);
//unset the arrays with the taken times for server 1
while($query1 = mysql_fetch_array($sql1)) {
unset($timelist1[$query1[ start_time ] - 1]);
}
//unset the arrays with the taken times for server 2
while($query2 = mysql_fetch_array($sql2)) {
unset($timelist2[$query2[ start_time ] - 1]);
}
//unset the arrays with the taken times for server 3
while($query3 = mysql_fetch_array($sql3)) {
unset($timelist3[$query3[ start_time ] - 1]);
}
//now see which times are missing three times in a row and make one final array of available times.
//code goes here...
}
?>