How can i integrate php to html table -


my friend made new design table couldnt integrate old table php code new design. how can make it? thanks

this old table;

<table align="center" width="1200" height="370" cellpadding="7">               <tr>                 <th>id</th>                 <th>name</th>                 <th>sex</th>                 <th>country</th>                 <th>age</th>                 <th>twitter</th>                 <th>instagram</th>                 <th>snapchat</th>                 <th>details</th>             </tr>              <?php             foreach($db->query('select * uyeler order rand()limit 20') $row) {                     echo "<tr><td>" .$row['id'] . "</td>";                     echo "<td>" .$row['fname'] . "</td>";                     echo "<td>" .$row['sex'] . "</td>";                     echo "<td>" .$row['country'] . "</td>";                     echo "<td>" .$row['age'] . "</td>";                     echo "<td>" .$row['twitter'] . "</td>";                     echo "<td>" .$row['instagram'] . "</td>";                     echo "<td>" .$row['snapchat'] . "</td>";                     echo ('<td><a href="details.php?id=' .$row['id'] . '" title="panel">details</a></td>');                     echo "</tr>";                 }             ?>              </table> 

this new design, (one line dark, 1 line black....)

<table class="table table-striped">                                  <!--table header -->                                     <tr>                                         <th class="t_head">id</th>                                         <th class="t_head">name</th>                                         <th class="t_head">sex</th>                                         <th class="t_head">country</th>                                         <th class="t_head">age</th>                                         <th class="t_head">twitter</th>                                         <th class="t_head">instergram</th>                                         <th class="t_head">snapchat</th>                                         <th class="t_head">details</th>                                     </tr>                                  <!--row 01 -->                                       <tr class="t_light">                                         <td>14</td>                                         <td>taha</td>                                         <td>male</td>                                         <td>russia</td>                                         <td>2000</td>                                         <td>tahains</td>                                         <td>male</td>                                         <td>male</td>                                         <td><a href="#">details</a></td>                                     </tr>                                  <!--row 02 -->                                       <tr class="t_dark">                                         <td>14</td>                                         <td>taha</td>                                         <td>male</td>                                         <td>russia</td>                                         <td>2000</td>                                         <td>tahains</td>                                         <td>male</td>                                         <td>male</td>                                         <td><a href="#">details</a></td>                                     </tr>                                  <!--row 03 -->                                       <tr class="t_light">                                         <td>14</td>                                         <td>taha</td>                                         <td>male</td>                                         <td>russia</td>                                         <td>2000</td>                                         <td>tahains</td>                                         <td>male</td>                                         <td>male</td>                                         <td><a href="#">details</a></td>                                     </tr>                                  <!--row 04 -->                                       <tr class="t_dark">                                         <td>14</td>                                         <td>taha</td>                                         <td>male</td>                                         <td>russia</td>                                         <td>2000</td>                                         <td>tahains</td>                                         <td>male</td>                                         <td>male</td>                                         <td><a href="#">details</a></td>                                     </tr>                                  <!--row 05 -->                                       <tr class="t_light">                                         <td>14</td>                                         <td>taha</td>                                         <td>male</td>                                         <td>russia</td>                                         <td>2000</td>                                         <td>tahains</td>                                         <td>male</td>                                         <td>male</td>                                         <td><a href="#">details</a></td>                                     </tr>                                  </table> 

a part of css file;

.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th {     background: #e0dfdf; }  .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {     background: #f7f7f7; } 

you can follows

<table align="center" width="1200" height="370" cellpadding="7">     <tr>         <th class="t_head">id</th>         <th class="t_head">name</th>         <th class="t_head">sex</th>         <th class="t_head">country</th>         <th class="t_head">age</th>         <th class="t_head">twitter</th>         <th class="t_head">instergram</th>         <th class="t_head">snapchat</th>         <th class="t_head">details</th>     </tr>     <?php     $i=1;     foreach($db->query('select * uyeler order rand()limit 20') $row) {         if ($i%2!=0)             $class="t_light";         else             $class="t_dark";         echo "<tr class='".$class."'><td>" .$row['id'] . "</td>";         echo "<td>" .$row['fname'] . "</td>";         echo "<td>" .$row['sex'] . "</td>";         echo "<td>" .$row['country'] . "</td>";         echo "<td>" .$row['age'] . "</td>";         echo "<td>" .$row['twitter'] . "</td>";         echo "<td>" .$row['instagram'] . "</td>";         echo "<td>" .$row['snapchat'] . "</td>";         echo ('<td><a href="details.php?id=' .$row['id'] . '" title="panel">details</a></td>');         echo "</tr>";         $i++;     }     ?> </table> 

what have done that, inside each loop checks whether each of iteration wwhether odd or , applies class appropriately.

i think, using such code style alternate rows differently. can done css selectors. no need adding separate classes rach rows.

in pure css can following:

//for tr:nth-child(even) {     background-color: #000000; } //for odd tr:nth-child(odd) {     background-color: #ffffff; } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -