0

I am looking for table row alternating color. I already write the codes and the table does not appears yet. I wonder why?

schedule.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Transdmin Light</title>

<!-- CSS -->
<link href="style/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie6.css" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="style/css/ie7.css" /><![endif]-->

<!-- JavaScripts-->
<script type="text/javascript" src="style/js/jquery.js"></script>
<script type="text/javascript" src="style/js/jNice.js"></script>
</head>

<body>
    <div id="wrapper">
        <!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
        <h1><a href="#"><span>Transdmin Light</span></a></h1>
        <img src="images/logo2.png" height="70px" style="margin: -45px 0 0 -180px; position: absolute;"><br><!--<img src="images/admin.png" height="60px" style="margin: -20px 0 0 430px">--><br><br>
        <!-- You can name the links with lowercase, they will be transformed to uppercase by CSS, we prefered to name them with uppercase to have the same effect with disabled stylesheet -->
        <ul id="mainNav">
            <li><a href="#" class="active">DASHBOARD</a></li> <!-- Use the "active" class for the active menu item  -->
            <li><a href="#">ADMIN PAGE</a></li>
            <li class="logout"><a href="#">LOGOUT</a></li>
            <li class="logout"><a href="#"><img src="images/mail.png"></a></li>
            <li class="logout"><a href="#">ADMIN</a></li>           
        </ul>
        <!-- // #end mainNav -->

        <div id="containerHolder">
            <div id="container">
                <div id="sidebar">

                    <?php include("admin_nav.php"); ?>

                    <!-- // .sideNav -->
                </div>    
                <!-- // #sidebar -->

                <div style="margin: -15px 0 0 230px; width: 700px; position: absolute;">
                <!-- h2 stays for breadcrumbs -->
                <h2><a href="#">Dashboard</a> &raquo; <a href="#" class="active">Schedule</a></h2>
                </div>

                <!--
                <div id="main">
                    <form action="" class="jNice">
                    <h3>Group Management</h3>
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <td>Vivamus rutrum nibh in felis tristique vulputate</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr class="odd">
                                <td>Duis adipiscing lorem iaculis nunc</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr>
                                <td>Donec sit amet nisi ac magna varius tempus</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr class="odd">
                                <td>Duis ultricies laoreet felis</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                            <tr>
                                <td>Vivamus rutrum nibh in felis tristique vulputate</td>
                                <td class="action"><a href="#" class="view">View</a><a href="#" class="edit">Edit</a><a href="#" class="delete">Delete</a></td>
                            </tr>                        
                        </table>
                    <h3>Edit Group Info</h3>
                        <fieldset>
                            <p><label>Group Name:</label><input type="text" class="text-long" /></p>
                            <p><label>Information:</label><input type="text" class="text-medium" /><input type="text" class="text-small" /><input type="text" class="text-small" /></p>
                            <p><label>Package:</label>
                            <select>
                                <option>Select one</option>
                                <option>Select two</option>
                                <option>Select tree</option>
                                <option>Select one</option>
                                <option>Select two</option>
                                <option>Select tree</option>
                            </select>
                            </p>
                            <p><label>Other Information:</label><textarea rows="1" cols="1"></textarea></p>
                            <input type="submit" value="Submit Query" />
                        </fieldset>
                    </form>
                </div> -->

                <!-- // #main -->

                <!-- Insert New -->

                <div id="inputberita">

      <br><br><br><br><br><br>
      <center>
        <h2 style="left: -270px; position: relative;">Next Class</h2>
      </center>


      <p>&nbsp;</p>

  <p>&nbsp;</p><center>

<?php         

      include('includes/koneksi.php');


    //Hapus schedule list


    if (!empty($_GET['class_list_id']))
        {
        $class_list_id = $_GET['class_list_id'];
        $result = mysql_query("DELETE FROM class_list WHERE class_list_id =".$class_list_id) or die(mysql_error());

        $confirmation = !$result ? "Fail to save data." : "Data has been saved."; 
        }


?>

    <?php 
    /*
                include('../../includes/koneksi.php');

                // FIND TOTAL ROWS

                echo "CREATE PAGING";

                $result = mysql_query("SELECT *, COUNT(class_list_id) AS NumberOfRows FROM class_list WHERE class_list_id='".$_GET['class_list_id']."' GROUP BY group") or die(mysql_error());
                $data = mysql_fetch_array($result);
                echo "post_parent: ".$data['post_parent'];
                echo " Total Rows :".$data['NumberOfRows'].'<br>';
                $totalrows = $data['NumberOfRows'];     
    */          
    ?>

<br><br><br><br><br> 
<div align="center">
    <div style="width:700px;text-align:left;padding-top:5px;">
        <?php  if (isset($confirmation)) { echo $confirmation; } ?>  
        <form method="get" action="<?php $_SERVER['PHP_SELF'] ?>">

                                    <br/>

                        <button type="button" onClick="parent.location='add_class_list.php'">Add New Class Schedule</button><br><br>

                <?php
                //LOAD CLASS LIST

                $sqlstr = "SELECT * FROM class_list 
                INNER JOIN `group` 
                ON class_list.group_id = `group`.group_id
                INNER JOIN teacher
                ON class_list.teach_id = teacher.teach_id
                INNER JOIN class
                ON class_list.class_id = class.class_id
                WHERE datetime > '".date('Y-m-d H:i:s')."' ORDER BY class_list_id";


                $result = mysql_query($sqlstr) or die(mysql_error());                   

                ?>
                <table id="admintable" border="1" cellpadding="2" cellspacing="0" style="width: 900px;">
                    <tr>
                        <th>Next Class List</th><th>Attendance List</th><th>Teacher</th><th>Material</th><th>Short Intro</th><th>datetime</th><th>Post</th>
                    </tr>
                    <?php
                    $i=0;
                    while ($data = mysql_fetch_array($result)){
                    $result2=($i%2)?'#DFA09D':'white';

                            $short_intro = $data['short_intro'];
                            $class_list_id = $data['class_list_id'];
                            $datetime = $data['datetime'];


                            echo "<tr bgcolor='$result2'>";                  
                            echo '<td><a href="add_class_list.php?class_list_id='.$data['class_list_id'].'">'.$data['class_name'].'</a></td>';

                            echo '<td>'.$data['group_name'].'</td>';
                            echo '<td>'.$data['teach_fname'].'&nbsp;'.$data['teach_lname'].'</td>';
                            //echo '<td>'.$data['material'].'</td>';
                            echo '<td><br>';

                            $rs = mysql_query("SELECT * FROM `material` where class_name='".$data['class_name']."'") or die(mysql_error());

                            while($data = mysql_fetch_array($rs)){                  
                                echo $data['material'].'<br>';                   
                            }                   

                            echo '<br></td>';
                            echo '<td>'.$short_intro.'</td>';
                            echo '<td>'.$datetime.'</td>';
                            echo '<td><a href="schedule.php?class_list_id='.$class_list_id.'">Delete</td>';                            
                            echo '</tr>';

                    $i++;   
                    }
                    ?>
                </table>

        </form>
    </div>
</div>
  </center>
</div>  

<br><br>

<div id="inputberita">
      <center>
       <br>
        <h2 style="left: -270px; position: relative;">History</h2>
      </center>


      <p>&nbsp;</p>

  <p>&nbsp;</p><center><br><br><br><br><br>

<?php         

      include('includes/koneksi.php');


    //Hapus schedule list


    if (!empty($_GET['class_list_id']))
        {
        $class_list_id = $_GET['class_list_id'];
        $result = mysql_query("DELETE FROM class_list WHERE class_list_id =".$class_list_id) or die(mysql_error());

        $confirmation = !$result ? "Fail to delete data." : "Data has been saved."; 
        }


?>
<div align="center">
    <div style="width:700px;text-align:left;padding-top:5px;">
        <?php  if (isset($confirmation)) { echo $confirmation; } ?>  
        <form method="get" action="<?php $_SERVER['PHP_SELF'] ?>">


                        <!--<button type="button" onClick="parent.location='add_class_list.php'">Add New Class Schedule</button><br><br> -->

                <?php
                //LOAD CLASS LIST HISTORY

                $sqlstr = "SELECT * FROM class_list 
                INNER JOIN `group` 
                ON class_list.group_id = `group`.group_id
                INNER JOIN teacher
                ON class_list.teach_id = teacher.teach_id
                INNER JOIN class
                ON class_list.class_id = class.class_id
                WHERE datetime < '".date('Y-m-d H:i:s')."' ORDER BY class_list_id";

                $result = mysql_query($sqlstr) or die(mysql_error());                   

                ?>
                <table id="admintable" border="1" cellpadding="2" cellspacing="0" style="width: 900px;">
                    <tr>
                        <th>Next Class List</th><th>Attendance List</th><th>Teacher</th><th>Material</th><th>Short Intro</th><th>datetime</th><th>Post</th>
                    </tr>
                    <?php
                    $i=0;
                    while ($data = mysql_fetch_array($result)){
                    $result2=($i%2)?'#DFA09D':'white';

                            $short_intro = $data['short_intro'];
                            $class_list_id = $data['class_list_id'];
                            $datetime = $data['datetime'];


                            echo "<tr bgcolor='$result2'>";                  
                            echo '<td><a href="add_class_list.php?class_list_id='.$data['class_list_id'].'">'.$data['class_name'].'</a></td>';

                            echo '<td>'.$data['group_name'].'</td>';
                            echo '<td>'.$data['teach_fname'].'&nbsp;'.$data['teach_lname'].'</td>';
                            //echo '<td>'.$data['material'].'</td>';
                            echo '<td><br>';

                            $rs = mysql_query("SELECT * FROM `material` where class_name='".$data['class_name']."'") or die(mysql_error());

                            while($data = mysql_fetch_array($rs)){                  
                                echo $data['material'].'<br>';                   
                            }                   

                            echo '<br></td>';
                            echo '<td>'.$short_intro.'</td>';
                            echo '<td>'.$datetime.'</td>';
                            echo '<td><a href="schedule.php?class_list_id='.$class_list_id.'">Delete</td>';                            
                            echo '</tr>';

                    $i++;   
                    }
                    ?>
                </table>

        </form>
    </div>
</div>
  </center>
</div>           

                <!-- End Insert -->  

                <div class="clear"></div>
            </div>
            <!-- // #container -->
        </div>   
        <!-- // #containerHolder -->

        <p id="footer">Feel free to use and customize it. <a href="http://www.perspectived.com">Credit is appreciated.</a></p>
    </div>
    <!-- // #wrapper -->
</body>
</html>
3
Contributors
2
Replies
15
Views
2 Years
Discussion Span
Last Post by mattster
0

What exactly is your issue? Is the table not giving you any rows or is your alternating background not working?

I normally assign attributes to the cell not the row, but I do this with CSS not old-school attributes eg style="backgound-color: white;"

1

style="backgound-color: white;"

Use a CSS file instead, will save you a lot of work:

tr:nth-child(even) {background: #CCC}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.