Greaser9780 Posted February 15, 2007 Share Posted February 15, 2007 How would I even go about this.I figured out the query and how to list my array. I would like to create a table visible to users that displays my array. I would also like it to automatically set the number of rows by the number of clan names in that database. Link to comment https://forums.phpfreaks.com/topic/38603-php-to-create-a-table-displayed-on-page/ Share on other sites More sharing options...
JJohnsenDK Posted February 15, 2007 Share Posted February 15, 2007 Where do you pull the clan names from? database or do you just type them in a array? If database do something like this: <table> <?php $result = mysql_query("SELECT name FROM clans"); while($row = mysql_fetch_array($result)){ echo "<tr><td>'$row['name']'</td></tr>"; } ?> </table> If in array use a foreach loop... Link to comment https://forums.phpfreaks.com/topic/38603-php-to-create-a-table-displayed-on-page/#findComment-185270 Share on other sites More sharing options...
Greaser9780 Posted February 15, 2007 Author Share Posted February 15, 2007 Here is my code where I pull it up from the db in an array: $sql="SELECT `clan_name`,`wins`,`losses`,`message`,`clan_id`,`link` FROM `bhdsingle` ORDER BY `wins` DESC"; $res=mysql_query($sql) or die(mysqll_error()); while ($list = mysql_fetch_array($res)) { $clan_name = $list["clan_name"]; $wins = $list["wins"]; $losses = $list["losses"]; $message =$list["message"]; $clan_id = $list["clan_id"]; $link = $list["link"]; } Link to comment https://forums.phpfreaks.com/topic/38603-php-to-create-a-table-displayed-on-page/#findComment-185273 Share on other sites More sharing options...
New Coder Posted February 15, 2007 Share Posted February 15, 2007 $sql="SELECT `clan_name`,`wins`,`losses`,`message`,`clan_id`,`link` FROM `bhdsingle` ORDER BY `wins` DESC"; $res=mysql_query($sql) or die(mysqll_error()); while ($row = mysql_fetch_array($res)) { $list = "<table>"; $list .= "<tr>"; $list .= "<th>Clan Name</th>"; $list .= "<td>".$row["clan_name"]."</td>"; $list .= "<tr>"; $list .= "</table>"; echo( $list ); } Add more columns etc to suit when you know how you want table displayed Link to comment https://forums.phpfreaks.com/topic/38603-php-to-create-a-table-displayed-on-page/#findComment-185277 Share on other sites More sharing options...
Greaser9780 Posted February 15, 2007 Author Share Posted February 15, 2007 thank you for pointing me in the right direction. Definitely going to have to fiddle with it for awhile. I have 5-6 items to be used as table data. So if I wanted to display "clanname"-"wins"-"losses" I would need to set up a new while statement for each set of table data. Link to comment https://forums.phpfreaks.com/topic/38603-php-to-create-a-table-displayed-on-page/#findComment-185280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.