Jump to content

php to create a table displayed on page


Greaser9780

Recommended Posts

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
Share on other sites

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
Share on other sites

$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.