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
Share on other sites

This is the add points file:


mysql_select_db("b7_463487_LPS", $con);

mysql_query("UPDATE points SET Points = '$_GET[Points=points+1]'
WHERE FirstName = '$_GET[firstname]' AND LastName = '$_GET[lastname]'");

echo "$_GET[firstname] now has $_GET[Points] points";

Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.