Jump to content

PHP scripts WITH ARGUMENTS from a button


basicxman
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...