简体   繁体   中英

PHP on a site with dynamic content

SO FAR I have made a website which is connected to a MYSQL database. On the website I have many buttons, each button corresponds to a table in my database. When I click the button, a javascript function opens my php file in this form

xmlhttp.open("GET", "addPoint.php?q=" + name, true); Where name is the name of the table

Back to the html. I have a div with an ID that will update with whatever the PHP echos.

The div is now populated with table, reflecting the table in mysql. This all works fine.

Here is the problem: I am trying to implement a voting system, where you vote by clicking on one of the elements of the newly created table. AFAIK the MYSQL updating which will need to happen for the vote to work, will need to be done in PHP, which means that I need to tell the PHP file

  1. The name of the table
  2. The name of the element

I am reluctant to use forms because I would like to just be able to click some text, NOT have to fill in a form or click a radio button.

So how do I get these 2 bits of info to a PHP file? Is the structure which I am doing this any good or should I step back and redesign?

Thanks for reading please let me know if I have been ambiguous.

Familiarize yourself with JQuery . It's great for projects like these.

http://www.w3schools.com/jquery/default.asp

As Norse already alluded to, use javascript to submit a "form" request for you. The javascript can populate the table and element values for you based on the button which was clicked. It is up to you whether this is a GET/POST.

JQuery would be a great way to help make this easier, but you don't need it if you don't want it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM