im trying to make a webpage for my hockey league and i need a way where i can have them click on a team and it takes them to the teamprofile.php page but only show the team they clicked. Im not sure what this is called i looked up paging but that isn't what i was looking for.

example:
Standings
Team1
Team2

OnClick on Team1 goto teamprofile.php?=Team1

    will you be storing teamprofiles in a DB??

    if so, just do a query once you get the variable on the next page, access it with $_GET['id'] if you have a link like <a href="teamprofile.php?id=1">Team Whatever</a>

    then since you have the id of the team, you can just do a sql query on that id and get all the pertinent information on that particular team

    i'm not sure how to fully answer your question, but that gives you an idea i guess

    hth,
    stolzyboy

      that gives me the idea i was looking for. ill give it a try and see what happens

        There are many ways to do what you wanna do...

        First, the most basic :

        <?
         $strTeam = strtolower(@$_GET['id']); // The @ prevents any error messages from being shown. We convert the team name to lower case so STANDINGS is the same as standings...
         if($strTeam == 'standings') {
            echo 'Data for Standings<br />' . "\n";
         } elseif($strTeam == 'team1') {
            echo 'Data for Team 1<br />' . "\n";
         } elseif($strTeam == 'team2') {
            echo 'Data for Team 2<br />' . "\n";
         } else {
           echo 'No team specified.';
         }
        ?>
        

        Another one :

         $strTeam = strtolower(@$_GET['id']); // The @ prevents any error messages from being shown. We convert the team name to lower case so STANDINGS is the same as standings...
        switch($strTeam) {
            case 'standings':
                echo 'Data for Standings<br />' . "\n";
                break;
            case 'team1':
                echo 'Data for Team 1<br />' . "\n";
                break;
            case 'team2':
                echo 'Data for Team 2<br />' . "\n";
                break;
            default:
                echo 'No team specified.';
        }
        

        Another one...

         $strTeam = strtolower(@$_GET['id']); // The @ prevents any error messages from being shown. We convert the team name to lower case so STANDINGS is the same as standings...
        if(file_exists('./includes/' . $strTeam . '.php')) {
            require_once './includes/' . $strTeam . '.php';
        } else {
            echo 'No team specified.';
        }
        

        .......

          i really dont understand this.
          i have a link
          phpTest.php?District=Smithtown
          and my php

          <label id="label1">
          <?php
          $strTeam = strtolower(@$_GET['District']);
          Print $strTeam;
          ?>
          </label>

          why wouldnt this print out 'smithtown'?

            You can create a database table for your teams called teams and use a page like this to pull a list of teams from the database creating links to another page that will display the info you want. (Just change data to suit your needs)

            teams.php

            // retrieve all the rows from the database
               $query = "SELECT DISTINCT category FROM `teams` ORDER BY team ASC";
            
               $results = mysql_query( $query );
            
               // print out the results
               if( $results )
               {
                  while( $contact = mysql_fetch_object( $results ) )
                  {
                     // print out the info
                     $id = $contact -> id;
                     $team = $contact -> team;
                     $stats = $contact -> stats;
            
                 echo( "<h3>&nbsp;&nbsp;&nbsp;&nbsp;* <a href='teamsorter.php?sorter=$team'>$team</a>");

            Then create a page to display your information:
            teamsorter.php

            // Make the query.
            $query = "SELECT team, stats, id FROM teams WHERE (team LIKE '$sorter')  ORDER BY $order_by team ASC";		
            $result = @mysql_query ($query); // Run the query.
            
            // Table header.
            echo '<table align="center" cellspacing="0" cellpadding="5">
            
            <tr>
            
            <td align="left"><b>Team</b></td>
            <td align="left"><b>Stats</a></b></td>
            
            </tr>
            ';
            
            // Fetch and print all the records.
            $bg = '#eeeeee'; // Set the background color.
            while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
            	$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
            	echo '<tr bgcolor="' . $bg . '">
            		<td align="left">' . $row['team'] . '</td>
            		<td align="left">' . $row['stats'] . '</td>
            	</tr>
            	';
            }
            
            echo '</table>';
              5 days later

              I have a similar question/issue.

              I wrote this very simple script:

              test.php

              <?php
              $name = $_get['id'];
              echo $name;
              ?>

              Now, when I type this in the browsers address bar:

              test.php/?id=alexsch8

              I get nothing, just a blank page. The variable from the address bar is blank.

              What do I need to do for the script to see the variable? Is there a setting in php.ini? I'm not looking for another solution, just why this doesn't work and what do I need to do in order to be able to use and react to the variable parsed via the address bar.

              Thank you.

                alexsch8 wrote:

                Now, when I type this in the browsers address bar:

                test.php/?id=alexsch8

                Looks like you have an extra "/" in your path

                It should read

                test.php?id=alexsch8

                See if this works.

                  $get is unknown to PHP... it HAS to be in capital letters : $GET, not $_get...

                    Thank you both respondents!

                    Yes, I had to change it to _GET (capitals) and then it sort of worked.

                    I actually had to do this:

                    <?php
                    $id = $_GET['id'];
                    echo $id;
                    ?>

                    Then it worked. I am using this script in Windows environment on PHP4. I don't know why I have to use the $_GET[] function. I saw another script that didn't need to do that. It was as simple as just echoing the variable.

                      alexsch8 wrote:

                      Thank you both respondents!

                      Yes, I had to change it to _GET (capitals) and then it sort of worked.

                      I actually had to do this:

                      <?php
                      $id = $_GET['id'];
                      echo $id;
                      ?>

                      Then it worked. I am using this script in Windows environment on PHP4. I don't know why I have to use the $_GET[] function. I saw another script that didn't need to do that. It was as simple as just echoing the variable.

                      it worked on another server/script, because register_globals was ON... default for register_globals is now OFF and the directive will be taken away fully in PHP6

                      so always use $GET, $POST, $_SESSION, etc... when referring to variables that are being passed form page to page, etc...

                      hth,
                      stolzyboy

                        Perfect. That explains all. I'll mark this as resolved.

                        Thank you all for your help.

                          Write a Reply...