retrieving id using button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naughtybynature
    New Member
    • Sep 2006
    • 9

    retrieving id using button

    Hello
    I would like to know if there's any possible code for retrieving
    id when we use button. Normally the button itself will only
    functions if we use form action, however if i only
    used that form action i can't pass the id value to the next particular
    form. Therefore, i usually used the link function to retrieve id.
    For example :

    Code:
    $result = mysql_query("SELECT * FROM gred",@ $db);
    $myrow = mysql_fetch_array($result);
    
    echo "<a href=\"addform_obj.php?id=".$myrow["id"]."\">tambah </a>";
    Hence I need the same function like the one that the above link did to retrieve id; but yet using the button.
  • TheMadMidget
    New Member
    • Oct 2006
    • 98

    #2
    $_REQUEST['id']

    Comment

    • ramurao24
      New Member
      • Nov 2006
      • 1

      #3
      beter use
      $id=mysql_fetch _field($field)

      Comment

      • naughtybynature
        New Member
        • Sep 2006
        • 9

        #4
        could both of you please give me some explaination... ?

        Comment

        • TheMadMidget
          New Member
          • Oct 2006
          • 98

          #5
          If you want the information from http://www.site.com/blah.php?id=sec tion1&name=John &sec=9324

          [PHP]
          echo $_REQUEST['id'] . "<br>";
          echo $_REQUEST['sec'] . "<br>";
          echo $_REQUEST['name'];
          [/PHP]
          If purposely have them in a different order to show that the order doesn't matter.
          The results from the above code are:
          Code:
          section1<br>9324<br>John
          And would show as:

          section1
          9324
          John



          Good?

          Comment

          • eigun
            New Member
            • Nov 2006
            • 1

            #6
            Maybe not to retrieving id using a button but...
            to submitting values(id) sent to a page using a button (without <form>...</form>)
            try this..

            [php]
            // --- main.php file ---
            //..........
            $result = mysql_query("SE LECT * FROM gred",@ $db);
            $myrow = mysql_fetch_arr ay($result);

            // echo "<a href=\"addform_ obj.php?id=".$m yrow["id"]."\">tambah </a>";

            // button to replace your link
            echo "<input type=\"button\" value=\"Tambah\ " onclick=\"locat ion.href='addfo rm_obj.php?id=" .$myrow["id"]."'\">";
            //..........
            [/php]
            [php]
            // --- example addform_obj.php file ---
            $var = @$_GET['id']; //catch the "id"
            echo "variabelny a : $var";
            [/php]

            GOOD LUCK...
            http://nugie.web.ugm.a c.id/

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #7
              naughtybynature : I can no longer follow this discussion, as I think it is way off your original question. So that's why I ask you: is your problem/question solved/answered in any way or do you still have an issue open? And if so, could you explain what is still to be answered.

              Thanks,

              Ronald :cool:

              Comment

              Working...