getting variable from a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaf
    New Member
    • Nov 2006
    • 2

    getting variable from a form

    i'm having a problem with my script ... anybody pls help. i'm new in php

    i want to use following url

    http://www.sanha.org.z a/view1.php?id=1

    the id=number part to search in database for its values and display online. i have the following script for view1.php

    <?php

    include(connect .php)

    $id = $_GET['id'];
    $search1 = "SELECT * FROM certified WHERE $id = 'certified.id'" ;
    $result = mysql_query($se arch1);

    while ($row = mysql_fetch_arr ay($result))
    {
    echo $row["CompanyNam e"];
    echo "<br>";
    }
    ?>

    the script returns empty. what wrong am i doing ????
  • Nert
    New Member
    • Nov 2006
    • 64

    #2
    Originally posted by jaf
    http://www.sanha.org.z a/view1.php?id=1

    the id=number part to search in database for its values and display online. i have the following script for view1.php

    <?php

    include(connect .php)

    $id = $_GET['id'];
    $search1 = "SELECT * FROM certified WHERE $id = 'certified.id'" ;
    $result = mysql_query($se arch1);

    while ($row = mysql_fetch_arr ay($result))
    {
    echo $row["CompanyNam e"];
    echo "<br>";
    }
    ?>

    the script returns empty. what wrong am i doing ????

    hi,

    ahmmn i found something wrong in your code i guess! maybe the column $id in your query statement is wrong because you have already declaired a variable $id before your query having the value from $_GET.

    i'll make a small changes on your code and try it, maybe this will help you.

    <?

    include("connec t.php");

    $id = $_GET['id'];
    $search1 = "SELECT * FROM certified WHERE id = '$id'";
    $result = mysql_query($se arch1);

    while ($row = mysql_fetch_arr ay($result)) {
    echo $row["CompanyNam e"];
    echo "<br>";
    }

    ?>


    --nert

    Comment

    • jaf
      New Member
      • Nov 2006
      • 2

      #3
      [QUOTE=Nert]hi,

      ahmmn i found something wrong in your code i guess! maybe the column $id in your query statement is wrong because you have already declaired a variable $id before your query having the value from $_GET.

      i'll make a small changes on your code and try it, maybe this will help you.

      thanx man, saved my day.... :)

      Comment

      • Nert
        New Member
        • Nov 2006
        • 64

        #4
        [QUOTE=jaf]
        Originally posted by Nert
        hi,

        ahmmn i found something wrong in your code i guess! maybe the column $id in your query statement is wrong because you have already declaired a variable $id before your query having the value from $_GET.

        i'll make a small changes on your code and try it, maybe this will help you.

        thanx man, saved my day.... :)
        hi,

        always welcome...(^_^)


        --nert

        Comment

        Working...