Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在表中垂直显示数据库中的数据_Php_Html_Mysql - Fatal编程技术网

Php 在表中垂直显示数据库中的数据

Php 在表中垂直显示数据库中的数据,php,html,mysql,Php,Html,Mysql,我想在表中垂直显示与日期相关的时隙。 这是此代码的输出: 但我想显示水平显示的时间,应该垂直显示。例如,第一行的1-3、3-5、5-7应显示在星期一下方,然后下一行应显示在星期二下方,依此类推。尝试使用如下查询: //This code to split time into intervals $starttime = $row['start_time']; // your start time $endtime = $row['end_time']; // En

我想在表中垂直显示与日期相关的时隙。 这是此代码的输出:


但我想显示水平显示的时间,应该垂直显示。例如,第一行的1-3、3-5、5-7应显示在星期一下方,然后下一行应显示在星期二下方,依此类推。

尝试使用如下查询:

    //This code to split time into intervals

    $starttime = $row['start_time'];  // your start time
    $endtime = $row['end_time'];  // End time
    $duration = $row['slot_time'];  

    $array_of_time = array ();
    $start_time    = strtotime ($starttime); //change to strtotime
    $end_time      = strtotime ($endtime); //change to strtotime

    $add_mins  = $duration * 60;

    while ($start_time <= $end_time) // loop between time
    {
        echo '<td>';
        echo "<div align=\"center\">";
        print_r(date ("h:i", $start_time) ."-". date("h:i", $start_time += $add_mins));
        //
        echo "</br><input type=\"radio\" name=\"texi\" value=\"1\" ></input>";
        echo '</td>' ;
        echo '</div>';
    }
    echo "</tr>";
    echo "</tbody>";
}            

mysqli_close($con);

echo  "</table>
       </div>
       <input type=\"submit\" value=\"Book Slot\"  class=\"button_drop\">
       </form>";
?>
这样可以更容易地处理数据。我看不到您的确切数据结构,但看起来您应该得到7x
01:00-03:00
,然后是7x
03:00-05:00
,等等。每一组都应该按天排列。然后,您可以按照数据来自数据库的顺序写出
s。跟踪
日期
值的变化时间(或最多7次),并在该时间开始新的

    //This code to split time into intervals

    $starttime = $row['start_time'];  // your start time
    $endtime = $row['end_time'];  // End time
    $duration = $row['slot_time'];  

    $array_of_time = array ();
    $start_time    = strtotime ($starttime); //change to strtotime
    $end_time      = strtotime ($endtime); //change to strtotime

    $add_mins  = $duration * 60;

    while ($start_time <= $end_time) // loop between time
    {
        echo '<td>';
        echo "<div align=\"center\">";
        print_r(date ("h:i", $start_time) ."-". date("h:i", $start_time += $add_mins));
        //
        echo "</br><input type=\"radio\" name=\"texi\" value=\"1\" ></input>";
        echo '</td>' ;
        echo '</div>';
    }
    echo "</tr>";
    echo "</tbody>";
}            

mysqli_close($con);

echo  "</table>
       </div>
       <input type=\"submit\" value=\"Book Slot\"  class=\"button_drop\">
       </form>";
?>
SELECT day FROM time_slot ORDER BY time_slot, day;