Jump to content

Recommended Posts

Hi all,

 

how can i put my code , the echo results in a html table :

 

$qres = mysql_query("SELECT * FROM `$clubprefix"."_player` WHERE id='$id'");  

WHILE ($row = mysql_fetch_array ($qres, MYSQL_ASSOC))
{

$FB=$row['FB'];
$FM=$row['FM'];
$SR=$row['SR'];
$Vol=$row['Vol'];
$SS=$row['SS'];
$PS=$row['PS'];
$TE=$row['TE'];



echo "Forehand/Backhand 	:$FB <br>" .
             "Fitness/Movement 		:$FM <br>" .
     "Serve/Return 		:$SR <br>" .
     "Volley			:$Vol <br>" .
     "Special Shots	 	:$FB <br>" .
     "Playing Style	 	:$FB <br>" .
     "Tournament Experience 	:$FB <br>" ;
   

 

i want to put the name and the variable in different columns on the same row

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/201291-echo-results-in-html-table/
Share on other sites

<?php

$qres = mysql_query("SELECT * FROM `$clubprefix"."_player` WHERE id='$id'");  

//Start table and create table headers
$results = "<table>\n";
$results .= "<tr>\n";
$results .= "<th>Forehand/Backhand</th>\n";
$results .= "<th>Fitness/Movement</th>\n";
$results .= "<th>Serve/Return</th>\n";
$results .= "<th>Volley</th>\n";
$results .= "<th>Special Shots</th>\n";
$results .= "<th>Playing Style</th>\n";
$results .= "<th>Tournament Experience</th>\n";
$results .= "</tr>\n";

//Output the data
WHILE ($row = mysql_fetch_array ($qres, MYSQL_ASSOC))
{
    $results .= "<tr>\n";
    $results .= "<td>{$row['FB']}</td>\n";
    $results .= "<td>{$row['FM']}</td>\n";
    $results .= "<td>{$row['SR']}</td>\n";
    $results .= "<td>{$row['Vol']}</td>\n";
    $results .= "<td>{$row['SS']}</td>\n";
    $results .= "<td>{$row['PS']}</td>\n";
    $results .= "<td>{$row['TE']}</td>\n";
    $results .= "</tr>\n";
}
  
//Close the table
$results .= "</table>\n";

?>
<html>
<head></head>

<body>

<div id="tableOutput">
<?php echo $results; ?>
</div>

</body>
</html>

 

I put the results in a variable as it is better form to include the logic at the top of your page and display the results in the body of the page.

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.