www.webdeveloper.com
Results 1 to 4 of 4

Thread: Multiple color in table row

Hybrid View

  1. #1
    Join Date
    Aug 2013
    Posts
    40

    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

    Code:
    <html>
    <head>
    <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" />
    </style>
    </head>
    
    <body>
    <p>MM/DD/YYYY</p><form action="" method="POST">
    <input type=text name=search >
    <input type=submit name=submit value=Search>
    
    </form>
    </body>
    </html>
    
    <?php
       
       $date=date("m/d/Y");
       echo "Today Date Is = ";
       echo "$date";
    
       include("connection.php");
       $table="baltimore";
       
    
       if(isset($_POST['submit']))
    
       {
    
    
    	$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.
    
    	$check=mysql_query($selectcondition,$con);
    	$fetch=mysql_fetch_row($check); 
    
    
    		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']."'";
             	
    
    	         	$mydata=mysql_query($sql,$con);
    			//$fetch_rows=mysql_fetch_row($mydata);
    		
    			 echo "<table width='100%' height='10%' border='1' cellspacing='0'>
                  
    				 <tr  bgcolor='#FF6600'>
    		                  <th>MODIFIED DATE</th>
    		                  <th>Sample ID</th>
    		                  <th>ORDER</th>
    		                  <th>STATUS</th>
    						  <th>DESCRIPTION</th>
    			              
                  		 </tr>";
    			
    			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

    Code:
    @charset "utf-8";
    /* CSS Document */
    
    .mytable {
    	width:100%;
    	border-collapse:collapse;
    }
    
    .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
    Posts
    1,144
    (Sorry... my mistake.)
    Rick Trethewey
    Rainbo Design

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

    Code:

    **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
    Posts
    40
    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



Recent Articles