bugmero Posted May 10, 2010 Share Posted May 10, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/201291-echo-results-in-html-table/ Share on other sites More sharing options...
Psycho Posted May 10, 2010 Share Posted May 10, 2010 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/201291-echo-results-in-html-table/#findComment-1056067 Share on other sites More sharing options...
bugmero Posted May 10, 2010 Author Share Posted May 10, 2010 Thanks mjdamato , i worked great Quote Link to comment https://forums.phpfreaks.com/topic/201291-echo-results-in-html-table/#findComment-1056079 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.