Forums

[resolved] Passing Variables with method=GET in Page (4 posts)

  1. okelly01
    Member
    Posted 2 years ago #

    hello everybody

    Simple problem is driving me nuts. I've installed Exec-PHP which is working correctly It appears from the code below that the "id" variable is not getting passed correctly to the script below from the URL String. Here's the URL. Note it shows blank results for id=28
    http://xbrlplanet.org/wp/?page_id=275?id=28
    The script and Exec-PHP work prefectly otherwise if I hardcode the variable value as follows projects.id = '28'....so something is wrong with my GET statement..

    Any ideas?
    Thanks
    Conor

    <?php
    //the database connection from config is tested and works correctly
    include('../admin/config.php');
    //get the variable from the URL String- this bit doesnt seem to be working
    $id= $_GET['id'] ;
    // get the data records from the database
    $select = ("SELECT projects.id, projects.name, projects.cat, projects.url, projects.wiki, projects.wikiurl, projects.iso3166
            FROM
            projects
            WHERE
            projects.id =  '$id'
            ");
        $result = mysql_query($select) or die(mysql_error());
    
    //Start table and loop thru results
    echo "<table width=306 border=0 cellspacing=1 cellpadding=1>";
    # Dislay your rows here in the loop
    while($row = mysql_fetch_array($result))
    {
    extract ($row);
    echo "  <tr>";
    echo "   <td align=left valign=top width=25% bgcolor=#E9E9E9>Project id</td>";
    echo "   <td align=left valign=top width=75% bgcolor=#E9E9E9>" . $id. "</td>";
    echo "  </tr>";
    echo "  <tr>";
    echo "    <td align=left valign=top width=25% bgcolor=#E9E9E9>Agency</td>";
    echo "    <td align=left valign=top width=75% bgcolor=#E9E9E9>" .$name. "</td>";
    echo "  </tr>";
    }
    echo "</table>";
    # close the loop and close the table
    
    ?>
  2. jonradio
    Member
    Posted 2 years ago #

    http://xbrlplanet.org/wp/?page_id=275?id=28 is not correct.

    It should be http://xbrlplanet.org/wp/?page_id=275&id=28 -- standard GET coding of URLs begins with a ? and continues with &

  3. okelly01
    Member
    Posted 2 years ago #

    you're absolutely right adiant..
    Thanks very much!

  4. Mark / t31os
    Moderator
    Posted 2 years ago #

    Marking resolved as it appears you have the answer you were looking for.. :)

Topic Closed

This topic has been closed to new replies.

About this Topic