Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 30th, 2004, 06:57 AM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to tell which button clicked

Hi,

In my webpage I query a mysql database for records and display them on the page using php, in a loop. Next to each item I put a button for the user to interact with that particular item; currently I give the button's 'name' attribute the value of the item's primary key.

The problem is that I can't figure out how to tell, on the form-processing page, which of these buttons was pressed by the user to get there, since the names are generated at run-time so I can't just test for each one in advance. I've tried setting a session variable in the 'onClick' attribute of the button but it doesn't seem to work.

Any suggestions?

Thanks!
Reply With Quote
  #2 (permalink)  
Old November 30th, 2004, 08:53 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

if ini_set() can handle 'session.use_trans_sid' variable, use it else a hidden form field can transit $_POST or $_GET values to action page.

Reply With Quote
  #3 (permalink)  
Old November 30th, 2004, 01:35 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.

I don't entirely understand your first suggestion; I tried googling it and then tried setting it to 'true', but this didn't seem to change anything.

I don't understand either how a hidden form field would help, since how would I know what it was called in order to see what value it had? The problem is that I don't know in advance the number of items that will be displayed, and therefore their primary keys/names.

Ideally I would like to be able to say 'give me the name of the button that was clicked' since that would tell me the primary key, but I can't say 'was it button x, was it button y' etc. since I don't know x, y, z in advance.

The only thing I can think of is that the primary keys are auto-increment integers, i.e. 1, 2, 3, 4...etc so I could keep checking if $form_1, $form_2, $form_3 etc. were set until I found it, but presumably it's not possible to dynamically change a variable $form_x to those values incrementally at run-time?

Thanks again, and sorry if/that I've missed the point completely.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form does not open when commandbar button clicked Arsi BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 21 March 5th, 2009 04:03 AM
How to know whick button was clicked. KingArthur Struts 1 February 22nd, 2006 07:12 AM
Determining Which Button Was Clicked BrianWren ASP.NET 1.0 and 1.1 Basics 3 May 5th, 2005 03:24 PM
links to a page when a button is clicked hosefo81 HTML Code Clinic 4 December 7th, 2003 06:47 AM



All times are GMT -4. The time now is 11:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.