Jump to content

Help with href processing


JohnOP

Recommended Posts

I have a few links to buy gifts from a store and handle the clicks with jquery sop i can update the database without page refresh, when i set the links to diffrent id's and process them 1 by 1 it works ok but i want to save load and process all the hrefs in one like so.

 

$(document).ready(function (){

$("#gt").click(function(){

$.get("processgift.php", { 
gift: $('#gt').attr('gift') 

});

});

});

<a href="#" id="gt" gift="roses"><img src="gifts/roses.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"></a>
<a href="#" id="gt" gift="chocs"><img src="gifts/chocs.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE; "></a>
<a href="#" id="gt" gift="wine"><img src="gifts/wine.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"></a>
<a href="#" id="gt" gift="meal"><img src="gifts/meal.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"></a>
<a href="#" id="gt" gift="flowsers"><img src="gifts/flowers.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"></a>
<a href="#" id="gt" gift="tea"><img src="gifts/tea.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"></a>
<br /><br />
<a href="#" id="gt" gift="necklace"><img src="gifts/necklace.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE; "></a>
<a href="#" id="gt" gift="loveheart"><img src="gifts/loveheart.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"></a>
<a href="#" id="gt" gift="wink"><img src="gifts/wink.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"></a>
<a href="#" id="gt" gift="popcorn"><img src="gifts/popcorn.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"> </a>
<a href="#" id="gt" gift="ring"><img src="gifts/ring.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"> </a>
<a href="#" id="gt" gift="kiss"><img src="gifts/kiss.jpg" style="margin-left: 20px; height: 100px; width: 100px; border: 2px solid #EDEDEE;"> </a>


 

But that way nothing updates, anyway i can do this?

 

processgift.php

 

$gift = $_GET['gift'];


$username = $_SESSION['username'];


include("connect.php");



mysql_query("UPDATE gifts SET $gift = $gift+1 WHERE username = '$username'");

Link to comment
https://forums.phpfreaks.com/topic/243423-help-with-href-processing/
Share on other sites

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.