imsry Posted December 29, 2014 Share Posted December 29, 2014 The code works but the title is repeated with each new set of data. I want the titles set up at the top and never repeating... No idea what is causing it. $conn = new mysqli($servername, $username, $password, $dbname); $sql = "SELECT deadchar, level, class, killforumid, realm, date FROM pkdata ORDER BY deadchar DESC"; $result = $conn->query($sql); while($row = $result->fetch_assoc()) { $deadchar = $row['deadchar']; $level = $row['level']; $class = $row['class']; $killforumid = $row['killforumid']; $realm = $row['realm']; $date = $row['date']; $conn->close(); echo "<table><center><tr> <th> <font size=3 color=#070719>Victim</font> </th> <th> <font size=3 color=#070719>Level</font> </th> <th> <font size=3 color=#070719>Class</font> </th> <th> <font size=3 color=#070719>Killer</font> </th> <th> <font size=3 color=#070719>Realm</font> </th> <th> <font size=3 color=#070719>Date</font> </th> </tr></center>"; echo "<tr><center> <td><center>$deadchar</center></td> <td><center>$level</center></td> <td><center>$class</center></td> <td><center>$killforumid</center></td> <td><center>$realm</center></td> <td><center>$date</center></td> </tr>"; echo "</table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/293462-my-table-is-repeating-titles/ Share on other sites More sharing options...
QuickOldCar Posted December 29, 2014 Share Posted December 29, 2014 (edited) You had everything within the loop, so it showed every time Added some css, you can style it additional <style type="text/css"> .tg {color:black;border-collapse:collapse;border-spacing:0;} .tg td{color:red;font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;} .tg th{color:green;font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;} </style> <?php $conn = new mysqli($servername, $username, $password, $dbname); $sql = "SELECT deadchar, level, class, killforumid, realm, date FROM pkdata ORDER BY deadchar DESC"; $result = $conn->query($sql); echo " <table class='tg'> <tr> <th class='tg'>Victim</th> <th class='tg'>Level</th> <th class='tg'>Class</th> <th class='tg'>Killer</th> <th class='tg'>Realm</th> <th class='tg'>Date</th> </tr>"; while($row = $result->fetch_assoc()) { $deadchar = $row['deadchar']; $level = $row['level']; $class = $row['class']; $killforumid = $row['killforumid']; $realm = $row['realm']; $date = $row['date']; echo " <tr> <td class='tg'>$deadchar</td> <td class='tg'>$level</td> <td class='tg'>$class</td> <td class='tg'>$killforumid</td> <td class='tg'>$realm</td> <td class='tg'>$date</td> </tr>"; } echo '</table>'; $conn->close(); ?> Edited December 29, 2014 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/293462-my-table-is-repeating-titles/#findComment-1500997 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.