dave_55 Posted March 30, 2008 Share Posted March 30, 2008 Hi, can anyone help me. I want my table to display everything under the headings Date, HomeAwayGame, Home Team, Away Team and not like it does at the moment - Does anyone know how to do this??? Date: 2007-09-08 HomeAwayGame: Home HomeTeam: Lincoln AwayTeam: Nottingham Moderns Date: 2007-09-15 HomeAwayGame: Away HomeTeam: Sleaford AwayTeam: Lincoln My Code is - <title>2nd Team Fixtures</title> <?php $database = "localhost"; //login to the server $username = "dave"; //username login $password = "*****"; //password login //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to Lincoln Database"); echo "Connected to Lincoln Database<br><br>"; //select a database to work with $selected = mysql_select_db("lincolnrugby",$dbhandle) or die("Could not select lincoln rugby"); $result = mysql_query("SELECT * FROM 2ndfixtures"); //execute the SQL query and return records while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // Loop through all the rows // Set some variables to the $row array $Date = $row['Date']; $HomeAwayGame = $row['HomeAwayGame']; $HomeTeam = $row['HomeTeam']; $AwayTeam = $row['AwayTeam']; // Display the information echo " Date: $Date <br> HomeAwayGame: $HomeAwayGame <br> HomeTeam: $HomeTeam <br> AwayTeam: $AwayTeam <br><br>"; } //close the connection mysql_close($dbhandle); ?> Link to comment https://forums.phpfreaks.com/topic/98712-re-adability-of-tables/ Share on other sites More sharing options...
cunoodle2 Posted March 30, 2008 Share Posted March 30, 2008 This should do the trick... <title>2nd Team Fixtures</title> <?php $database = "localhost"; //login to the server $username = "dave"; //username login $password = "*****"; //password login //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to Lincoln Database"); echo "Connected to Lincoln Database"; //select a database to work with $selected = mysql_select_db("lincolnrugby",$dbhandle) or die("Could not select lincoln rugby"); $result = mysql_query("SELECT * FROM 2ndfixtures"); //execute the SQL query and return records ?> <table> <tr> <td>Date</td> <td>Home/Away Game</td> <td>Home Team</td> <td>Away Team</td> </tr> <?php // Loop through all the rows while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // Display the information echo " <tr>\n"; echo " <td>".$row['Date']."</td>\n"; echo " <td>".$row['HomeAwayGame']."</td>\n"; echo " <td>".$row['HomeTeam']."</td>\n"; echo " <td>".$row['AwayTeam']."</td>\n"; echo " </tr>\n"; } //close off the table echo "</table>\n"; //close the connection mysql_close($dbhandle); ?> Link to comment https://forums.phpfreaks.com/topic/98712-re-adability-of-tables/#findComment-505166 Share on other sites More sharing options...
dave_55 Posted March 31, 2008 Author Share Posted March 31, 2008 Thats great thanks for your help. Link to comment https://forums.phpfreaks.com/topic/98712-re-adability-of-tables/#findComment-505587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.