Jump to content

php like system.


Recommended Posts

I have a php and jquery like system that doesn't work for some reason? When i click on the button to like it does nothing not even gives me an error please help thank you ! Here is my code that I am using and maybe you will see something that I didn't? The first part of the php code works it shows the like button so I know that's right but when you click it, it does nothing ...


$likes = mysql_query("SELECT lid FROM likes WHERE uid='$id' AND imid='$photoid'");
$likethis = '<a href="#" id="'.$photoid.'" title="like"><div class="like"></div></a>';
$unlikethis = '<a href="#" id="'.$photoid.'" title="unlike"><div class="unlike"></div></a>';


<script type="text/javascript">
$(document).bind('click', '.like', function(){


if ($action=='like'){
$sql= mysql_query("SELECT * FROM likes WHERE imid=$imid and uid=$id");
$sql= mysql_query("INSERT INTO likes (imid, uid) VALUES($imid, $id)");
$sql= mysql_query("UPDATE photos SET likes=likes+1 WHERE id=$imid");
die("There is No Image With That ID");
if ($action=='unlike'){
$sql= mysql_query("SELECT * FROM likes WHERE imid=$imid and uid=$id");
if ($matches!=0){
$sql=mysql_query("DELETE FROM likes WHERE imid=$imid AND uid=$id");
$sql=mysql_query("UPDATE photos SET likes=likes-1 WHERE id=$imid");

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.

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.