スケジュールの表を作成していますが、正しくフォーマットできません。ここに私の出力テーブルがどのように見えるかがあります
Users| Action | Monday | Monday | Monday | Wednesday
09/23/13 09/23/13 09/23/13 09/25/13
11:00 AM 1:00 PM 2:00 PM 10:00 AM
----- -------- ---------- --------- ----------- -----------
Jack
John
Tim
出力を次のようにします。
Users| Action | Monday | Monday | Monday | Wednesday
09/23/13 09/23/13 09/23/13 09/25/13
11:00 AM 1:00 PM 2:00 PM 10:00 AM
----- -------- ---------- ----------- ------------- ---------
Jack
John * * *
Tim *
new
これは、2 つのテキスト ファイルからデータを読み取っています。1 つは次のようなスケジュール用です。
2013-09-23^11:00|13:00|14:00
ユーザーファイルのインデックスでこのように視覚化される場所
0 1 2
2013-09-23^11:00|13:00|14:00
各番号がユーザーにマップされる場所
例:ユーザーファイル
Jack
John^0|1|3
Tim^2
John の 0 は、スケジュール ファイルの最初の日付にマップされ、マークされます。
ここに私のコードを修正する方法はありますか? スケジュール ファイルが読み込む列に基づいて、最初にユーザーごとに空白行を挿入する必要があります...
<!DOCTYPE html>
<html>
<head>
<title>Scheduler</title>
</head>
<body>
<h2>
<form action = "update.php" method = "POST" >
<center>Select Your Meeting Times</center></h2>
<?php
echo "<table border= '1'
cellpadding='10'>
<tr>
<th>User</th>
<th>Action</th>";
date_default_timezone_set('America/New_York');
//error_reporting(1);
getTimes();
displaySchedule();
function displaySchedule()
{
// used for displaying schedule times
$text = "user.txt"; // open up the user file.
$f = fopen($text, "r+");
if (file_exists("user.txt"))
{
while($line = fgets($f,1000))
{
$name = getUsers($text, $line);
echo "<tr>" . "<td>" . $name . "</td>" . "</tr>\n";
}
}else{
#create the file method.
}
echo "<tr>" . "</tr>";
}
#this method gets the users from the text file and diplays them.
function getUsers(&$text1, &$line)
{
list($name, $num) = explode('^', $line);
$num1 = explode('|', $num); // num 1 now holds the number where the time entry mark goes
// setTimes($name, $num1) // sets the times for the user.
return $name;
}
#When the user is either new or active, set the times
function setTimes(&$name, &$num1)
{
}
function getTimes()
{
$file = file("schedule.txt"); // open up the schedule file
// loop through the schedule file
foreach($file as $s){
# s = string like '2013-04-11^12:00|4:00|14:00'
list($year, $rest) = explode("^", $s);
$rest_arr = explode("|", $rest); // time = 12:00 etc..
list($year, $month, $day) = explode('-', $year); // this cuts them down.
$year= intval($year, 10);
$month= intval($month, 10);
$day= intval($day, 10); $h = mktime(0, 0, 0, $month, $day,$year);
$d = date("F dS, Y", $h); //used to get the day of the week
$w= date("l", $h); // w now holds the day of the week.
// while through the schedule file, loop through each of times and displays them.
foreach($rest_arr as $time){
//$convert = (string)$rest_arr;
//$convertedTime = date("g:ia", strtotime($convert));
echo "<th>" . $w . "<br>" . $month . "/" . $day . "/" . $year . "<br>" . $time . "</th>\n";
// sets the header
} // end this
} // end 1st foreach for file.
}
function createFile()
{
}
function drawTable()
{
$rows = 10; // define number of rows
$cols = 4;// define number of columns
echo "<table border='1'>";
for($tr=1;$tr<=$rows;$tr++){
echo "<tr>";
for($td=1;$td<=$cols;$td++){
echo "<td>row: ".$tr." column: ".$td."</td>";
}
echo "</tr>";
}
echo "</table>";
}
echo "<th><br></th>
<tr>
<th>Total</th>
</tr>
</table>";
?>
</body>
</html>