Jump to content

PHP scripts WITH ARGUMENTS from a button


basicxman

Recommended Posts

OK, here's the run down. I have a database that contains a news table. Each record of the news table has title, and news, and points (plus date, time, approval but they are irrelevant to my question)I've made a PHP script to list all the news records on a page and each record is shown 'Title, submitted on date' then <br /> and it shows the news.What I want to do though is have two buttons, a true/like and then a false/dislike button. When you click the true button it adds a point and then when you click the false button it subtracts a point. So I was going to add a form with the two buttons in an echo and place it beside each recordthe forms action would be <?=$_SERVER['PHP_SELF'];?> and a script on the same page would use if(isset...) on each button and then execute the MySql command(s) and set cookies so the same user cannot choose againalthough the thing is, I need to know which record of news im setting points for, how can i do this? i.e. if a user clicks true beside the news entitled 'Robot saves life' I need to add a point to the 'Robot saves life' entry and not another one on the page.

Link to comment
Share on other sites

I would suggest adding a column to the table and give each row it's own id number. Then have the form detect the id number of the news that the form is affecting, and then add or subtact points to the corresponding row that has that id number in the database. Typically in tables, you would have such a column already in existence to keep track of separate rows.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...