简体   繁体   English

用HTML创建时间表

[英]Create a timetable with HTML

I want to make a timetable in HTML of my weekly schedule at work. 我想以每周工作时间表的HTML格式制作时间表。 I already have a database that's functioning with hourly slots of where I'm meant to be. 我已经有一个可以按小时定位的数据库。

How would I go about making this in HTML? 我将如何使用HTML进行制作? I can create a table in html but how would I exactly go about plotting what I want exactly? 我可以用html创建一个表格,但是如何精确地绘制我想要的东西呢?

Here is a mockup of what I'm trying to make: 这是我要制作的模型: 在此处输入图片说明

It's very hard to offer a helpful/direct answer because we don't really know the scheme of your database. 很难提供有用/直接的答案,因为我们并不真正了解您的数据库方案。 If you are wondering how to get information and iterate it into a table, there is a good (albeit dated and poorly styled) tutorial here . 如果你想知道如何获得信息,并迭代它插入一个表格,有一个很好的(虽然过时,风格不佳)的教程在这里

To go over what it says quickly, the first thing you want to do is connect to your database. 要快速浏览一下内容,首先要做的就是连接到数据库。 There is a good article on Nettuts discussing the best practices of accessing a database, but since we're just starting off we can just use the following (I encourage you to revisit the code and use what you learned at Nettuts to write something using PDO): 在Nettuts上有一篇不错的文章 ,讨论了访问数据库的最佳实践,但是由于我们刚开始,我们可以使用以下内容(我鼓励您重新访问代码,并使用在Nettuts上学到的知识来使用PDO编写某些东西。 ):

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

Once you've connected, all you need to do is (1) query the database (in this case we're looking for all records in a table): 连接后,您所需要做的就是(1)查询数据库(在这种情况下,我们正在查找表中的所有记录):

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

And (2) loop through the results using a while loop 和(2)使用while循环遍历结果

<table>
<?php
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<td><?php echo $rows['theNameOfYourRow']; ?></td>
<?php
}
?>
</table>

Again, I strongly encourage you to review some of the database best practices tutorials on nettuts, they have a bunch of really good ones enter link description here . 同样,我强烈建议您回顾一些数据库对NETTUTS最佳实践教程, 他们有真的很不错的人在这里输入链接的描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM