How to run a PHP function due to a button click with button data passed

0 votes

I manage some sortiment items on a page, they get displayed with a PHP script. I want an admin page that "toggle" via a sortiment table to display or not display an item. 
Scenario: if the button is clicked, I would like to start a php-skript. There should be a value passed to that script from where the button was clicked.
The table entry looks like this:

<tr>
    <td>Himbeerhonig</td>
    <td id="himbeerhonig">Ja</td>
    <td><button type="button" id="himbeerhonig" onclick="function()">press me to execute function</button></td>
</tr>```

(possible PHP pseudocode)
open SQL connection
   look for database entry based on the passed ID
   change the value of the found entry (!currentValue)
close SQL connection

*optionally*
refresh the <td id="himbeerhonig"> with the updated value. 

Can someone help me do this?

May 28 in PHP by Kichu
• 19,040 points
51 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to Validate Form Data With PHP?

Hey @kartik, The first thing we will do ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,700 points
1,249 views
0 votes
1 answer

What is a Cookie? How to create Cookies With PHP?

A cookie is often used to identify ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,700 points
2,014 views
0 votes
0 answers
0 votes
1 answer

How to Execute PHP function with onclick?

Hello @kartik, In javascript, make an ajax function, function ...READ MORE

answered Jun 16, 2020 in PHP by Niroj
• 82,700 points
16,911 views
0 votes
1 answer

How to call a php function from ajax?

Hello @kartik, You can't call a PHP function ...READ MORE

answered Jun 16, 2020 in PHP by Niroj
• 82,700 points
9,244 views
0 votes
1 answer

How can I use jquery $.ajax to call a PHP function?

Hello @kartik, Use $.ajax to call a server context (or ...READ MORE

answered Aug 27, 2020 in PHP by Niroj
• 82,700 points
4,847 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,240 points
337 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

How to access PHP var from external javascript file?

Hello @kartik, You don't really access it, you ...READ MORE

answered Jul 6, 2020 in Java-Script by Niroj
• 82,700 points
4,334 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP