Jump to content

[SOLVED] Automatically adding 1


cheechm

Recommended Posts

Hi,

I have created a database for a house points system. Everything is working fine, but there is one thing I can't do. I want to be able to click a link, and for the person to have 1 point added to them. It goes like this so far:

 

$result = mysql_query("SELECT * FROM points");

while($row = mysql_fetch_array($result))
  {

$link = 'addpoints.php?firstname=' . $row['FirstName'] . '&lastname=' . $row['LastName'] . '&Points=' . $row['Points']; 
  echo "<a href='".$link."'>+points</a>"; 
  echo $row['FirstName'] . " " . $row['LastName'] ." ". $row['Tutor'] . " " . $row['Points'];  

 

The only thing I can't do, is add 1 point to the current amount of points. How would I do that?

 

Link to comment
https://forums.phpfreaks.com/topic/52729-solved-automatically-adding-1/
Share on other sites

in "addpoints.php"

<?php

$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];

mysql_query("UPDATE points SET points=points+1 WHERE firstname='$firstname' AND lastname='$lastname'");
?>

 

It would better to use a record id instead of firstname/lastname just in case you get 2 people with same name, plus it's more efficient.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.