Results 1 to 4 of 4

Thread: Multiple color in table row

  1. #1
    Join Date
    Aug 2013

    Multiple color in table row

    I have designed a CSS file after exploring it on the google about how to make a css file for produce multiple color in the table data.
    I added this CSS file in my php file but it's not working, i don't know why.

    Please find my code below.

    My Php file

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CHP Search Incidents</title>
    <link href="design.css"  type="text/css" rel="stylesheet" />
    <p>MM/DD/YYYY</p><form action="" method="POST">
    <input type=text name=search >
    <input type=submit name=submit value=Search>
       echo "Today Date Is = ";
       echo "$date";
    	$selectcondition = "SELECT * FROM order_details where DATE='".$_POST['search']."'"; //Select Query Which check the INCIDENT ID whether the TURNOVER for the given INCIDENT is exit or not.
    		if(!$fetch)            				//If checklist for the given date is not exit execute if condition 
    	                echo "<font color='red'>";
    			echo "<br>";
    			echo "No Order Found In The Database"; 
    			echo "<br>";
    	                echo "</font>";
    		 else //if the above condition is flase !
    		 	$sql= "select * from order_details where DATE='".$_POST['search']."'";
    			 echo "<table width='100%' height='10%' border='1' cellspacing='0'>
    				 <tr  bgcolor='#FF6600'>
    		                  <th>MODIFIED DATE</th>
    		                  <th>Sample ID</th>
    			while($records = mysql_fetch_array($mydata))
    	            	echo "<tr class='mytable'>";
    	            		echo "<td>" . $records['TIMESTAMPS'] . "&nbsp;</td>";
    	            		echo "<td>" . $records['SAMPLEID']. "&nbsp;</td>";
    	            		echo "<td>" . $records['ORDER'] . "&nbsp;</td>";
    	            		echo "<td>" . $records['STATUS'] . "&nbsp;</td>";
    						echo "<td align='center'>";
    						echo '<textarea  name="textarea" cols="100"  >'.$records['COMMENTS'].'</textarea><br>'; 
    					echo "</td>";
    			echo "</table>";
    MY CSS file

    @charset "utf-8";
    /* CSS Document */
    .mytable {
    .mytable td {
    	padding::8px;border:#999 1px solid;
    .myTable tr:nth-child(even) { /*(even) or (2n+0)*/
    background: #A4D1FF;
    .myTable tr:nth-child(odd) { /*(odd) or (2n+1)*/
    background: #EAF4FF;
    Please guys do reply me ASAP.

    Thanks alot in advance.

  2. #2
    Join Date
    Mar 2011
    (Sorry... my mistake.)
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Sep 2013
    You can also try without CSS, its simple.


    **var rowCount = document.getElementById("tableID").rows.length;
    var row = table.insertRow(rowCount);
    var cell1 = row.insertCell(0);
    cell1.style.backgroundColor = "yellow";
    cell1.innerHTML = "hey";
    var cell2 = row.insertCell(1);
    cell2.style.backgroundColor = "green";
    cell2.innerHTML = "hello";**
    Here its creating dynamically row for the table and filling different color to coloumns.

    hope this help..!! Thanks

  4. #4
    Join Date
    Aug 2013
    Thanks Priyanka

    I sorted out with my CSS file

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center