Page 1 of 1

Unusual results when displaying a table

Posted: Fri Dec 22, 2006 3:30 pm
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

Posted: Fri Dec 22, 2006 3:33 pm
by John Cartwright
can you show the html output? I don't really understand what you say is happening.

Posted: Fri Dec 22, 2006 4:00 pm
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

Posted: Fri Dec 22, 2006 4:03 pm
by John Cartwright
hmm

remove the colon on this line

Code: Select all

<td align='center'>$finalscore</td>; 

Posted: Fri Dec 22, 2006 4:13 pm
by PastorHank
Got it, Thank you