chris11 Posted June 1, 2009 Share Posted June 1, 2009 Im using a sortable script to sort the data from the database when printed out in a table. The issue im having is that each row in my data base is getting it's own head like so.. Course i would like only one head one table but still have the script. What i did as an easy step be4 was make the table head on its own with another table under it with the DB table. This is an issue because it causes things to not line up right if names are to big etc. Also no JS this way. // gets data $query = "SELECT id, filename, description, filesize, date FROM uploads"; $result = mysql_query($query) or die('Error, query failed'); if(mysql_num_rows($result) == 0){ echo "Database is empty <br>"; } else{ while(list($id, $name, $description, $filesize, $date) = mysql_fetch_array($result)){ echo "<table id=\"test1\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"sortable-onload-5-6r rowstyle-alt colstyle-alt no-arrow\">\n"; echo "<caption>The db</caption>\n"; echo "<thead>\n"; echo "<tr>\n"; echo "<th class=\"sortable-numeric\">Name</th>\n"; echo "<th class=\"sortable-numeric\">Date</th>\n"; echo "<th class=\"sortable-numeric\">Size</th>\n"; echo "<th class=\"sortable-date-dmy\">Info</th>\n"; echo "\n"; echo "</tr>\n"; echo "</thead>\n"; echo "<tbody>\n"; echo "<td><a href=\"download.php?id='.$id.'\">'.$name.'</a></td>\n"; echo "<td>$date</td>\n"; echo "<td>$filesize</td>\n"; echo "<td>$description</td>\n"; echo "</tbody>\n"; echo "\n"; } } ?> Any help would be awesome. Thanks Chris Link to comment https://forums.phpfreaks.com/topic/160516-solved-hm-print-db-in-table-with-table-header-mostly-html/ Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 this chunk should be before the while loop echo "<table id=\"test1\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"sortable-onload-5-6r rowstyle-alt colstyle-alt no-arrow\">\n"; echo "<caption>The db</caption>\n"; echo "<thead>\n"; echo "<tr>\n"; echo "<th class=\"sortable-numeric\">Name</th>\n"; echo "<th class=\"sortable-numeric\">Date</th>\n"; echo "<th class=\"sortable-numeric\">Size</th>\n"; echo "<th class=\"sortable-date-dmy\">Info</th>\n"; echo "\n"; echo "</tr>\n"; echo "</thead>\n"; echo "<tbody>\n"; edit: and this should be after the while loop echo "</tbody>\n"; echo "\n"; Link to comment https://forums.phpfreaks.com/topic/160516-solved-hm-print-db-in-table-with-table-header-mostly-html/#findComment-847121 Share on other sites More sharing options...
chris11 Posted June 1, 2009 Author Share Posted June 1, 2009 Right on. It worked. I was so hopped up on the HTML I didn't even think about that. Thanks very much Link to comment https://forums.phpfreaks.com/topic/160516-solved-hm-print-db-in-table-with-table-header-mostly-html/#findComment-847128 Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 dont forget to mark the topic solved Link to comment https://forums.phpfreaks.com/topic/160516-solved-hm-print-db-in-table-with-table-header-mostly-html/#findComment-847129 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.