显示从mysql mrbs日历的今天预订 [英] display todays bookings from mysql mrbs calendar

查看:172
本文介绍了显示从mysql mrbs日历的今天预订的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'am因为每个人都在这个新的东西的开始。
我试图得到正确的查询显示从MRBS日历预订从时间和房间的顺序实例房间1 10 -11,房间2从10-11房间1从11-14房间3从13 -15。
我从Rowland carson获取了一个数组样本一周,但我想要它每天显示,按时间顺序任何一个有任何想法?他们非常欢迎这将是在学校设置,以显示每天的预订在远征。
这是我今天的情况:

I´am as everyone is in the start of something new at this. I am trying to get the right query to display todays booking from a MRBS calendar in the order of time and room fo instance room 1 10 -11, room 2 from 10-11 room1 from 11-14 room 3 from 13-15. I got an array sample for a week from Rowland carson but I want it to display per day and in time order any one got any ideas?? they are very welcome this is going to be set up at a school to show booking per day in the expedition. this is what I have today:

     session_start();
$php_session_id = session_id();

$this_page = basename($_SERVER['PHP_SELF']);
if ($_SESSION[ThisPage] == $this_page)
{

}

define("ONE_DAY", (60*60*24));

$nowArray = getdate();

if ( $_POST[show_calendar] != "" ) // form submitted so capture data from it
{
    switch ( $_POST[show_calendar] )
    {
        case "chosen":
            if ( !checkdate($_POST['month'], $_POST['mday'], $_POST['year']))
            {
                $day = $nowArray['mday'];
                $month = $nowArray['mon'];
                $year = $nowArray['year'];
            }
            else
            {
                $day = $_POST['mday'];
                $month = $_POST['month'];
                $year = $_POST['year'];
            }
            break;


    }

}
else // first pass, form not submitted
{
    $day = $nowArray['mday'];
    $month = $nowArray['mon'];
    $year = $nowArray['year'];
}

$startTimestamp = mktime (0, 0, 0, $month, $day, $year);
$theDateArray = getdate($startTimestamp);

$theWeekday = $theDateArray['wday'];
if ($theWeekday > 1)
{
    $startTimestamp = $startTimestamp - ($theWeekday * ONE_DAY);
    $theDateArray = getdate($startTimestamp);
}

$theTimestamp = $startTimestamp;

$startingDateArray = getdate($startTimestamp);

$startYear = $theDateArray['year'];

$dispTimestamp = $startTimestamp;

//connect to database
$conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass)
    or die(mysql_error());
mysql_select_db($booking_db, $conn)  or die(mysql_error());

$get_entries = "select timestamp
    from $bookings
    order by timestamp desc
    limit 1
    "
    ;
$entries_result = mysql_query($get_entries) or die(mysql_error());
$data_row = mysql_fetch_object($entries_result);
$last_changed = $data_row->timestamp;

$get_rooms = "select *
    from $rooms
    order by id
    "
    ;
$rooms_result = mysql_query($get_rooms) or die(mysql_error());
$n_rooms = mysql_num_rows($rooms_result);
$n_cols = $n_rooms + 1;

$booking_block = "<TABLE align=center BORDER=1 CELLPADDING=5>\n";
$booking_block .= "<tr><td colspan=".$n_cols.">";
$booking_block .= "Room bookings for today ";
$booking_block .= $startingDateArray['mday']." ";
$booking_block .= $startingDateArray['month']." ";
$booking_block .= $startingDateArray['year']." ";
$booking_block .= "(Last change to any booking was made ";
$booking_block .= $last_changed;
$booking_block .= ")</td></tr>\n";
$booking_block .= "<tr><td align=right>".$startYear."</td>\n";

while ($rooms = mysql_fetch_array($rooms_result, MYSQL_ASSOC))
{
    $booking_block .= "<td>";
    $booking_block .= $rooms['room_name'];
    $booking_block .= "</td>";
}
$booking_block .= "</tr>\n";

for ($day_number = 0; $day_number <= 6; $day_number++)
{
    $booking_block .= "<tr>\n";
    $booking_block .= "<td align=right valign=top>";
    $endOfDay = $theTimestamp + ONE_DAY;
    $theDateArray = getdate($theTimestamp);
    if ($theDateArray['year'] != $startYear)
    {
        $startYear = $theDateArray['year'];
        $booking_block .= $startYear."<br>";
    }
    $booking_block .= date("D d M", $theTimestamp)."</td>\n";

    for ($room_number = 1; $room_number <= $n_rooms; $room_number++)
    {
        $get_bookings = "select *
            from $bookings
            where start_time >= $theTimestamp
            and start_time <= $endOfDay
            and room_id = $room_number
            order by start_time
            "
            ;
        $bookings_result = mysql_query($get_bookings) or die(mysql_error());
        $booking_block .= "<td valign=top>";
        if (mysql_num_rows($bookings_result) > 0)
        {
            while ($booking_entry = mysql_fetch_array($bookings_result, MYSQL_ASSOC))
            {
                $booking_block .= date("H:i", $booking_entry['start_time']);
                $booking_block .= "-";
                $booking_block .= date("H:i", $booking_entry['end_time']);
                $booking_block .= " ";
                $booking_block .= $booking_entry['name'];
                $booking_block .= "<br>\n";
            }
        }
        else
        {
            $booking_block .= "<br>";
        }
        $booking_block .= "</td>";
    }
    $booking_block .= "</tr>\n";
    $theTimestamp = $theTimestamp + ONE_DAY;
}

$booking_block .= "<tr><td colspan=".$n_cols." align=right>";
$booking_block .= "This web page rendered on ";
$booking_block .= $nowArray['mday']." ";
$booking_block .= $nowArray['month']." ";
$booking_block .= $nowArray['year']." ";

$booking_block .= "</table>\n";

// Close the database connection
mysql_close($conn);

?>

<html>
<head>
    <meta http-equiv="Content-Style-Type" content="text/css">
    <link type="text/css" rel="stylesheet" href="q_style.css">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title><?php echo "Room bookings for week of ".$startingDateArray['mday']." ".$startingDateArray['month']." ".$startingDateArray['year'] ?></title>
<head>
<body>

<?php include("page_header.php") ?>

<hr>

<table border=0 cellpadding=1 width="100%">
    <tr>
        <td align=right>&nbsp;</td>
    </tr>
</table>

<table align=center BORDER=0 CELLPADDING=5 width="100%">
    <tr>
        <td>
            <?php echo $booking_block; ?>     </td>
    </tr>
</table>

<table border=0 cellpadding=1 width="100%">
    <tr>
        <td>&nbsp;</td>
    </tr>
</table>

<hr>


推荐答案

此SQL将返回由start_time和room_id -

This SQL will return todays bookings ordered by start_time and room_id -

SELECT *
FROM $bookings
WHERE start_time >= UNIX_TIMESTAMP(CURRENT_DATE)
AND start_time < UNIX_TIMESTAMP(CURRENT_DATE + INTERVAL 1 DAY)
ORDER BY start_time, room_id

你正在寻找你将需要更多的努力在你的问题。什么是表名称及其结构?您希望输出的格式是什么?

If this is not what you are looking for you will need to put more effort into your question. What are the table names and their structures? What format are you expecting the output to be in?

这篇关于显示从mysql mrbs日历的今天预订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆