JohnOP Posted August 1, 2011 Share Posted August 1, 2011 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'"); Quote Link to comment https://forums.phpfreaks.com/topic/243423-help-with-href-processing/ Share on other sites More sharing options...
AyKay47 Posted August 1, 2011 Share Posted August 1, 2011 id's are unique, you cannot give multiple anchors the same id and expect this to work, I suggest giving them a specific class and grouping them that way Quote Link to comment https://forums.phpfreaks.com/topic/243423-help-with-href-processing/#findComment-1250014 Share on other sites More sharing options...
JohnOP Posted August 1, 2011 Author Share Posted August 1, 2011 Im not the best with jquery but i tried setting all the id's to classes and it was still the same, so i tried wrapping them in a div and calling $.get("processgift.php", { gift: $('#links a').attr('gift') }); Its still not working though. Quote Link to comment https://forums.phpfreaks.com/topic/243423-help-with-href-processing/#findComment-1250022 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.