Results 1 to 7 of 7

Thread: [RESOLVED] displaying data in a webpage.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    New York
    Posts
    74

    Resolved [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>&nbsp;</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.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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;
    }

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    New York
    Posts
    74

    Re: displaying data in a webpage.

    Quote 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!

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    New York
    Posts
    74

    Re: displaying data in a webpage.

    sorry.....

    I tried it and it worked, thanks.....

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: displaying data in a webpage.

    Don't forget to mark this thread Resolved from the Thread Tools menu above the first post.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    New York
    Posts
    74

    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
  •  



Click Here to Expand Forum to Full Width