SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need a little help.

    Hi,

    I have a quick question:

    All my code is running correctly but I want to show the viewers the item they are showing:

    On the side of my table I have the following Line:

    Showing records for ???

    The ??? could be GP, G, A, PTS or PIM

    how do you change them to read out in full. ie. Games Played, Goals etc.

    Thanx
    Spike

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you show us the code you're working with?
    Cross browser css bugs

    Dan Schulz you will be missed

  3. #3
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will try to:

    Showing records for $column_name

    <a href='$page_name?column_name=GP'>GP</a>
    <a href='$page_name?column_name=G'>Goals</a>

    And so on.

    Hope this helps, if you want the whole code I can email you it.

    Spike

  4. #4
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $column_name 
    strtoupper($_GET['column_name']);
    switch (
    $column_name) {
        case 
    'GP':
            
    $column_name 'Games Played';
            break;
        case 
    'G':
            
    $column_name 'Goals';
            break;
        default:
            
    $column_name 'Unknown Column';
    }
    echo 
    "Showing records for $column_name";
    ?>

  5. #5
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanx for the reply, it works like a treat, had to change $column_name so it clashed with the rest of the code.

    Many thanx again.
    Spike

  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I'm not knocking the solutions shown, just suggesting you think about doing it this way.

    <a href='$page_name?column_name=games-played'>Games played</a>
    <a href='$page_name?column_name=goals'>Goals</a>

    Then when posted back:
    PHP Code:
    $cols = array( 'games-played''goals''legs-broken' );

    if( 
    in_array$_GET['column_name'] , $cols ){
    // go on, go on...
    echo "You chose " ucwordsstr_replace"-"," "$_GET['column_name'] ) );

    }else{
    // oh no you dont


    The idea of this being :

    your table column names are now a bit more readable
    you can more easily manage the array of acceptable names, rather than add conditions to the switch, which can get hard to read once you have too many options
    you tighten up your security a tad by checking the var against a white-list

    Unless I have totally missed the point of your post of course.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •