|
-
Apr 3rd, 2007, 02:17 PM
#1
Thread Starter
Lively Member
[RESOLVED] displaying data in a webpage.
Hey guys,
I am learning to use mysql but what I lack is the knowledge of php. I am purchasing some books as to how to learn it so I can avoid asking you guys for help for the simpliest things.
Currently this is the page that I have.
I want to transfer all the pitchers and catchers, infielders and outfielders into an mysql database. For that code this is what I have:
Code:
<?
$dbh=mysql_connect ("localhost", "rgross_rgross", "mlg1984") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("rgross_40manrosternyy2007");
?>
<html>
<head>
<title>2007 NYY 40-Man Roster</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="roster.css" type="text/css" />
</head>
<body>
<div id="header">The 2007 NY Yankees 40-Man Roster</div>
<p> </p>
<table align="center" id="pitchers">
<tr class="title">
<td>NO.</td>
<td>First Name</td>
<td>Last Name</td>
<td>BAT</td>
<td>THW</td>
<td>HT</td>
<td>WT</td>
<td>DOB</td>
</tr>
<?
$get_teamdata = mysql_query("SELECT * FROM `pitchers` ORDER BY `id` ASC"); ?>
<tr class="info">
<td><?=$td['No.']; ?></td>
<td><?=$td['FName']; ?></td>
<td><?=$td['LName']; ?></td>
<td><?=$td['BAT']; ?></td>
<td><?=$td['THW']; ?></td>
<td><?=$td['HT']; ?></td>
<td><?=$td['WT']; ?></td>
<td><?=$td['DOB']; ?></td>
</tr>
</table>
</body>
</html>
Now I want the the actual rows to be #999999.
Any help? Thanks
Last edited by rgyankees23; Apr 3rd, 2007 at 05:23 PM.
-
Apr 3rd, 2007, 05:26 PM
#2
Re: displaying data in a webpage.
.. you just the rows to be that color? uhh. this really doesn't have anything to do with PHP. modify the "info" class in your style sheet to make all data fields (<TD>) inside of it colored appropriately.
Code:
tr.info td {
background-color: #999;
}
-
Apr 3rd, 2007, 05:29 PM
#3
Thread Starter
Lively Member
Re: displaying data in a webpage.
 Originally Posted by kows
.. you just the rows to be that color? uhh. this really doesn't have anything to do with PHP. modify the "info" class in your style sheet to make all data fields (<TD>) inside of it colored appropriately.
Code:
tr.info td {
background-color: #999;
}
it doesn't. Its just nothing to showing up. The databases are fully made!
-
Apr 3rd, 2007, 06:11 PM
#4
Re: displaying data in a webpage.
well, you should have said it wasn't displaying anything in your original post. your original post just stated that you had made a page and you wanted the rows to be a certain color :/. I didn't even bother looking through your code because of that.
anyway, you can't just send a query to the database without fetching results. use mysql_fetch_array() to fetch the results -- but don't forget to use a loop. something like:
PHP Code:
<?php
$q = mysql_query("SELECT fields FROM table ORDER BY key ASC");
while($a = mysql_fetch_array($q)){
print_r($a);
}
?>
inside the while() loop is where you will want to put the code that builds your tables. the print_r function will print out the raw data for each record in the meantime, to make sure your script works. adapt the query to what you want to do though, of course.
-
Apr 5th, 2007, 03:14 PM
#5
Thread Starter
Lively Member
Re: displaying data in a webpage.
sorry.....
I tried it and it worked, thanks.....
-
Apr 5th, 2007, 03:32 PM
#6
Re: displaying data in a webpage.
Don't forget to mark this thread Resolved from the Thread Tools menu above the first post.
-
Apr 5th, 2007, 03:34 PM
#7
Thread Starter
Lively Member
Re: displaying data in a webpage.
I didn't realize I could do that....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|