Print query when I parse ID

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricki Susic

    Print query when I parse ID

    Hi,
    Can anyone help me to get my query printed when I parse ID.

    Here is the code:

    [snip]

    FILE: udskriv.php

    <?php

    include("connec t.php");
    mysql_select_db ("DATABASE") ;
    $result = mysql_query("SE LECT ID, tekst, DATE_FORMAT(dat o, '%d %m %Y
    kl. %H:%i')as dato FROM TABLE ORDER BY ID desc LIMIT 0,3");
    while ($raekke = mysql_fetch_arr ay($result)){

    echo"<P>Indtast et dato: ".$raekke['dato']."</P>";
    $text = $raekke['tekst'];
    echo nl2br(substr($t ext,0,50));
    print "<a href='showpost. php?ID={$raekke["ID"]}'>Some Text</a>";




    }
    mysql_close($li nk);
    ?>

    FILE: showpost.php

    <?php

    include("connec t.php");
    $ID = $_POST['ID'];
    $sql = "SELECT tekst FROM TABLE WHERE ID=$ID";
    $result = mysql_query($sq l);
    echo "her er:".$result;

    mysql_close($li nk);




    ?>

    [snip]

    The problem is that I don't get any output from the database. Why?

    Ricki


  • sam

    #2
    Re: Print query when I parse ID

    1-In the file showpost.php change

    this line:
    $ID = $_POST['ID'];
    with this line:
    $ID = $_GET['ID'];

    You send the ID to showpost.php in the URL:
    <a href='showpost. php?ID={$raekke["ID"]}'>Some Text</a>

    So you get it in the $_GET array and not in the $_POST array.

    2- this line is wrong (here you print the resource id):

    echo "her er:".$result;

    instead :
    get the result from the resource id:
    $txt = mysql_fetch_row ($result);
    print the result:
    echo "her er:".$txt[0];

    HTH.



    "Ricki Susic" <rickFJERNDETTE i@webfabrikken. net> wrote in message
    news:3f572751$0 $97202$edfadb0f @dread12.news.t ele.dk...[color=blue]
    > Hi,
    > Can anyone help me to get my query printed when I parse ID.
    >
    > Here is the code:
    >
    > [snip]
    >
    > FILE: udskriv.php
    >
    > <?php
    >
    > include("connec t.php");
    > mysql_select_db ("DATABASE") ;
    > $result = mysql_query("SE LECT ID, tekst, DATE_FORMAT(dat o, '%d %m %Y
    > kl. %H:%i')as dato FROM TABLE ORDER BY ID desc LIMIT 0,3");
    > while ($raekke = mysql_fetch_arr ay($result)){
    >
    > echo"<P>Indtast et dato: ".$raekke['dato']."</P>";
    > $text = $raekke['tekst'];
    > echo nl2br(substr($t ext,0,50));
    > print "<a href='showpost. php?ID={$raekke["ID"]}'>Some Text</a>";
    >
    >
    >
    >
    > }
    > mysql_close($li nk);
    > ?>
    >
    > FILE: showpost.php
    >
    > <?php
    >
    > include("connec t.php");
    > $ID = $_POST['ID'];
    > $sql = "SELECT tekst FROM TABLE WHERE ID=$ID";
    > $result = mysql_query($sq l);
    > echo "her er:".$result;
    >
    > mysql_close($li nk);
    >
    >
    >
    >
    > ?>
    >
    > [snip]
    >
    > The problem is that I don't get any output from the database. Why?
    >
    > Ricki[/color]


    Comment

    • Ricki Susic

      #3
      Re: Print query when I parse ID

      Thank you. Now it works!

      Ricki


      Comment

      Working...