0

Hi i would like to know if it possible to, on the click of a button increment a variable then get the data from the row of the vale of the variable

eg. a = 0, when the button is clicked, a = 1 --> now get data from database record of row a?

please help!

fosho
  • 1,666
  • 6
  • 20
  • 28

1 Answers1

0

Yes, you can do it using AJAX:

  • Put an event handler on the button click.
  • Increment the value.
  • Send a request to the server with the new value.
  • Query the database with the parameter.
  • Return the request result to the caller.

Or directly in PHP, but your UX will suffer:

  • On button press, submit the new value in a form.
  • Query the database.
  • Print out a new page, with the incremented value.
Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
  • 1
    @DanielFeinstein this is already helpful. I'm not going to write the code for you, you'll have to try stuff out for yourself. If you have doubts about what StackOverflow is about, read the FAQ. If you encounter a specific problem, feel free to ask a new question. – Luchian Grigore Dec 12 '11 at 09:48
  • @fosho what exactly are you looking for then? – Luchian Grigore Dec 12 '11 at 10:01