Unusual results when displaying a table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Unusual results when displaying a table

Post by PastorHank »

I am retrieving and trying to display some results

Code: Select all

<?php

   $host="localhost"; 
   $user="myusername";
   $password="thepasswordiscorrect" ;
   $connection = mysql_connect($host,$user,$password) 
        or die("Couldn't Make the Connection"); 
   $database="mytable_football";
   $db = mysql_select_db($database,$connection)
   	 or die("Couldn't Select Database");

   $query = "SELECT * FROM mytable_football.standings ORDER BY 6 DESC";
   $result = mysql_query($query)
		or die ("Couldn't Execute Query.");
 
 
 echo "<table align='center' border='1'>";
  
 echo "<tr> <th>ID</th> 
 			<th>Place</th>
 			<th>User Name</th>
 			<th>Location</th>
 			<th>Wins</th>
 			<th>Losses</th>
 			<th>Champion</th>
			<th>Final Score</th>";

 while ($row = mysql_fetch_array($result)) {
  extract($row);

  echo "<tr>\n
  		<td align='center'>$id</td>
  		<td align='center'>$currentplace</td>
  		<td align='center'>$username</td>
  		<td align='center'>$city</td>
  		<td align='center'>$numberofwins</td>
  		<td align='center'>$numberoflosses</td>
  		<td align='center'>$champion</td>
		<td align='center'>$finalscore</td>;
		</tr>";
}

echo "</table>\n";
Once the data is retrieved all the appropriate records are there and they are ordered properly however, before the header row is displayed I have what appears to be multiple rows that contain only one field and the row has ";" in it's almost a duplicate table without the borders etc - and then the table displays properly.

Thank you
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

can you show the html output? I don't really understand what you say is happening.
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Post by PastorHank »

Not sure how to format this response, so please bear with me


The HTML output shows up on the screen as
;
;
;
;
;

this continues for the exact number of rows as in the resultset,

the table itself then appears correctly

ID Place User Name Location Wins Losses Champion Final Score ;
59 0 EnglishRedRaide Ipswich, Suffolk, England 2 0 OhioState 34-17 ;

NOW if I do a highlight and copy of the rows of semicolons, when I paste this shows up

;
39 0 mike sr. houston, 2 0 OhioState 45-21 ;
71 0 beaker Dallas 2 0 Florida 30 to ;
76 0 ORblack Clarkston 2 0 OhioState 35-24 ;

so it appears that the resultset is actually there at the beginning but so some reason gets blanked out and only leaves the semi-colons.....

And unfortunately, that's about as clear as I can make it...

Thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

hmm

remove the colon on this line

Code: Select all

<td align='center'>$finalscore</td>; 
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Post by PastorHank »

Got it, Thank you
Post Reply