[SOLVED] PHP outputting data in a html table
Posted: Tue Oct 19, 2004 7:14 pm
So I found a small piece of code from this book here page 13 is the example is the one I used if anybody has it and wants to use it for reference.
Basically here's the setup I have. I have a mySQL database that I have Track & Field Records stored in. I would like to display that data in a table on a php page. I used the example that was provided in the book and made some changes, mostly to the html code. The only difference in the php code from the book to what I keyed in is the mySQL connection string, otherwise it is copied line for line.
Well, I shouldn't have any problems, correct? Nope, I get the following error:
Here is all of the php code:
Again I just used an example out of the book so if you have a better idea by all means let me know...
Here's the site where I'm just doing the testing.
Thanks for your help!
blkshirt
Basically here's the setup I have. I have a mySQL database that I have Track & Field Records stored in. I would like to display that data in a table on a php page. I used the example that was provided in the book and made some changes, mostly to the html code. The only difference in the php code from the book to what I keyed in is the mySQL connection string, otherwise it is copied line for line.
Well, I shouldn't have any problems, correct? Nope, I get the following error:
I've looked at line 34 over and over again and I can't figure it out. Hopefully somebody here can help...My PHP Error wrote:Fatal error: Call to a member function on a non-object in /home/j9d2k0/public_html/ohhstrack/phptest/index.php on line 34
Here is all of the php code:
Code: Select all
<?php
//connect to the database
$dbh=mysql_connect ("localhost", "databasename", "databasepassword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("databasename");
//}
//query database for information
$sql = "SELECT ohsaabdiv1.Event,ohsaabdiv1.Effort,ohsaabdiv1.Name,ohsaabdiv1.School,ohsaabdiv1.Location,ohsaabdiv1.Year
FROM ohsaabdiv1
ORDER BY ohsaabdiv1.Event ASC";
$q = $dbh->query($sql);
if (DB::iserror($q)){
die($q->getMessage());
}
//generate the table
while ($q->fetchInto($row)){
?>
<tr><TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $rowї0] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $rowї1] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $rowї2] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $rowї3] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $rowї4] ?></td>
<TD class=text3 onmouseover="this.style.background='#CCCCCC'" onmouseout="this.style.background='#efefef'"><?= $rowї5] ?></td>
</tr>
<?php
}
?>Here's the site where I'm just doing the testing.
Thanks for your help!
blkshirt