0

我正在为时间表创建一个表格,但无法正确格式化它。这是我的输出表的样子

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

这是从两个文本文件中读取数据,其中一个用于时间表,如下所示:

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

约翰的 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>
4

0 回答 0