Php mysql and html tables

Hello i have my tables working an displaying in the table but the th for the table is showing in green every second line its the records i want to show underneath it you can see what i mean by looking here

This is the code

<?php include('styles/top.php'); ?>
 <div id="full">

    <div id="view_box">
        <ul>
            <li><img src="images/1.png" /></li>
            <!-- <li><img src="pics/2.jpg" /></li> -->
            <!-- <li><img src="pics/3.jpg" /></li> -->
        </ul>
    </div>
    
    <div id="button">
        <ul>
            <!-- <li><button class="button" scroll_value="0">*</button></li> -- >
            <!-- <li><button class="button" scroll_value="600">*</button></li> -->
            <!-- <li><button class="button" scroll_value="1200">*</button></li> -->
        </ul>
    </div>
    <hr /><br />
    
    
       <?php
    
    if (($user_level !=1) && ($user_level !=2)){
        echo "No Access Allowed";
    } else {
        
$mysqli = NEW MySQLI('','','','');

// How Many Records Per page
$rpp = 10;

// check for set page
isset($_GET['page']) ? $page = $_GET['page'] : $page = 0;

// check for page 1
if ($page > 1) {
    $start = ($page * $rpp) - $rpp;
} else {
    $start = 0;
}

// Query database for total Records

$resultSet = $mysqli->Query("SELECT id FROM orders");

// get total Records
$numRows = $resultSet->num_rows;

// get total number of pages
$totalPages = $numRows / $rpp;

// querys results
$resultSet = $mysqli->query("SELECT * FROM orders LIMIT $start, $rpp");

// start of the new table

echo "<table border=1>";

while ($rows = $resultSet->fetch_assoc()){
    $fullname = $rows['FullName'];
    $dategot = $rows['GotDate'];
    
    echo "
    
    <tr>
        <th>Name</th>
        <th>Date Got</th>
        <th>Pay Date</th>
        <th>Money Due</th>
        <th>update order status</th>
    </tr>
    
     <tr>
					<td>&nbsp;</td>
					<td></td>
					<td></td>
                    <td></td>
                    <td></td>
				</tr>
    
    <tr>
    
        <td>$fullname</td>
        <td>$dategot</td>
    
    </tr>";
}

echo "</table><p/>";

for($x = 1; $x <= $totalPages + 1; $x++)
{
    echo "<a href='?page=$x'> $x </a>";
}

 ?>
           
    <?php
    }
    ?>
<?php include('styles/bottom.php'); ?>

Did you look at the code? You put the < th > tags INSIDE your WHILE loop.
Move it ABOVE the WHILE loop and right after the echo “table” code.

So, display TABLE tag.
Display TR tag.
display all the TH tags.
THEN, start your WHILE loop and display the data.

I think you can get this one… Just don’t loop the table-headers each display of data…

Sponsor our Newsletter | Privacy Policy | Terms of Service