2011-04-26 68 views
1

我正在進行日曆預約,如果預訂不可用,我想在選項標籤中說預訂或隱藏。 在MySQL有時間表:如何從選項標籤中刪除某些行?

id time_reservation 
1 07:00 - 07:30 
2 07:30 - 08:00 
3 08:00 - 08:30 
. 
. 
. 
21 17:00 - 17:30 
22 17:30 - 18:00 
23 18:00 - 18:30 
24 18:30 - 19:00 
在其他表

存在與

ID 
NAME 
reservation_date 
**reservation_time** 
date_time 

$sql = "SELECT * FROM calendar_time"; 
$result = mysql_query($sql); 
echo "<form action='".$_SERVER['PHP_SELF']."' method='POST'>"; 
echo "<input name='datepicker' type='hidden' id='datepicker_value' />"; 
echo "<select name='res' class='res'>"; 
echo "<option value=''></option>"; 
while($row = mysql_fetch_array($result)){ 
    echo "<option value='".$row['time_reservation']."'>".$row['time_reservation']."</option>"; 
} 
echo "</select>"; 
echo "<input name='submit' type='submit' value='ressf' />"; 
echo "</form>"; 
+0

你正在做什麼問題? – Nacho 2011-04-26 12:22:55

+0

那麼我有工作系統所有工作正常進行預訂,它告訴如果保留,如果不可用,但我想在選項標記中說不可用或隱藏,如果它保留從日曆事件中獲取time_reservation並告訴選項標記隱藏它 – orion 2011-04-26 12:32:14

回答

0

假設calendar_time.time_reservation calendar_events表具有相同的格式比 calendar_events.reservation_time,你可以做你的查詢如:

SELECT time_reservation 
    FROM calendar_time 
    WHERE time_reservation NOT IN (
     SELECT reservation_time 
      FROM calendar_events 
      WHERE some_condition 
    ); 

由您來定義some_condition是什麼。

它可以是:reservation_date = $myDate或類似的東西,可能是name = '$myName'。我無法想象比這更多,因爲我不知道所有的背景。

+0

這很好,但不能成爲條件。這很好,但從所有日曆日中刪除了時間。你能幫我消除那一天的時間嗎?我會非常欣賞那個tnx。 – orion 2011-04-26 13:58:09

+0

@damirruff:看我的更新。 – Toto 2011-04-26 14:06:05