Jump to content

[SOLVED] Submitting a Form without a Submit button


Cruzer

Recommended Posts

Hello, This is my first time here and I'm a real newbie at PHP. I've written a number of pages where I've submitted forms, then use the $_POST to load this data into variables on the new page that I've called. This works fine.

 

However, now I am reading a MySQL database and displaying the records in an HTML table. But, instead of creating a form with a submit button, I would like to click on a hyperlink to post that data to the next webpage. The table consists of 4 columns - an image, a unique ID nbr, a description, and a selling price. (It's sort of a classifieds ad style page). I would like to use a mouseclick to select the graphic and/or one of the text columns to post the ID nbr to the next page so that I can display that item's details. I'm thinking I might have to use Javascript to do this but my fiddling with the onclick statement doesn't seem to do anything. Probably because I know even less about javascript than PHP. ;)

Link to comment
Share on other sites

For each item, add a simple html link like href='show-more.php?id=ID# and then show-more.php retrieves the passed id from the $_GET array.

 

<?php
// show-more.php
$ID = $_GET['id']; // passed by url
.. use ID to retrieve item data from database
...

Link to comment
Share on other sites

I originally tried that. I used an <href> statement to link to the new page but I did it sort of like

"href=newpage.php?<?php echo $adnbr ?>

but the URL just added the number of the ad after the base URL and I couldn't get the $_GET to retrieve the data to a PHP variable.

 

When I try it your way, and add the "ID=" to the adnbr, the $_GET function works and I can retrieve the data and put it into aPHP variable.

 

Thanks, that solved it.

 

I told you I was new at this. :)  ;D

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.