View Single Post
  #2 (permalink)  
Old March 27th, 2007, 11:17 AM
TheDudeTux TheDudeTux is offline
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Putter
 Can anyone help?...I am nearing the end of my rope!!!

I have adapted the code from pages 111 - 116 for my snooker teams database and cannot get the table to populate with data from my hosted database table. The table header comes back OK but there are no main table cells for the data to populate. I want to get to the stage where I can use links in the table to jump to other pages but cannot get past this hurdle. Can anyone please help ? My code looks like this;

<?php
$link = mysql_connect("localhost", "snooker", "password")
or die(mysql_error());
mysql_select_db("snooker")
or die (mysql_error());

$query = ("SELECT team_id, team_name, division_id FROM tbl_teams");
$result = mysql_query($query, $link)
or die(mysql_error());
$num_teams = mysql_num_rows($result);

$table_header = <<<EOD
<h2><center>Teams Database</center></h2>
<table width="70%" border="1" cellpadding="2"
       cellspacing="2" align="center">
  <tr>
    <th>Team ID</th>
    <th>Team Name</th>
    <th>Division ID</th>
  </tr>
</table>
EOD;

$table_details = '';
while ($row = mysql_fetch_array($result)) {
  $team_id = $row['team_id'];
  $team_name = $row['team_name'];
  $division_id = $row['division_id'];

  $table_details .=<<<EOD
  <tr>
   <td>$team_id</td>
   <td>$team_name</td>
   <td>$division_id</td>
  </tr>
EOD;
}

$table_details .=<<<EOD
<tr>
   <td>Total :$num_teams Teams</td>
  </tr>
EOD;

$table_footer = "</table>";

$teams =<<<TEAMS
  $table_header
  $table_details
  $table_footer
TEAMS;

  echo "There are $num_teams Teams in our database";
  echo $teams;
?>


 Hi, I don't have your database so I can't really debug it too much..to see what works or what doesn't. But I did notice one of your lines syntax was like this:

$table_header = <<<EOD

You might want to make it like this $table_header =<<<EOD
in order to take out the space.. Let me know if it works. Take care!
-TheDudeTux