What i am trying to do is to add a user following system (twitter like) to my script.This is how the db structure looks like:\[code\]CREATE TABLE IF NOT EXISTS `user_follow` ( `id` int(11) NOT NULL AUTO_INCREMENT, `follower` int(11) NOT NULL, `following` int(11) NOT NULL, `subscribed` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `follow_unique` (`follower`,`following`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;\[/code\]If i want create i should use this code:\[code\]mysql_query(" INSERT INTO `user_follow` (`follower`, `following`, `subscribed`) VALUES ('$follower', '$following', CURRENT_TIMESTAMP); ");\[/code\]For the unsubscribe it should look like this:\[code\]mysql_query(" DELETE FROM `user_follow` WHERE `follower` = '$follower' AND `following` = '$following'; ");\[/code\].\[code\]$follower = $_SESSION[user_id]; // the user_id for the one who is currently logged id $following = $user_id; // the user_id for the user profile where the script will be on\[/code\]On the profile page i have a form like this:\[code\]<?php if (isset($_SESSION[user_id]) && $_SESSION[user_id] != $user_id) { ?><form action="" method="post"><input name="action" type="hidden" value="http://stackoverflow.com/questions/10542901/<?php echo $subscribe_status; ?>"/><button name="subject" type="submit" value="http://stackoverflow.com/questions/10542901/<?php echo $subscribe_text.' '.$username; ?>"><?php echo $subscribe_text.' '.$username; ?></button></form><?php } ?>\[/code\]What i don't know is how to link all of those codes...EDIT:\[code\]$subscribe_status\[/code\] should change to \[code\]follow\[/code\] or \[code\]unfollow\[/code\] depending if the user is already following that user or not (by checking with a query i think).Also \[code\]$subscribe_text\[/code\] should be \[code\]Follow\[/code\] or \[code\]Unfollow\[/code\] depending if the currently logged in user (\[code\]$follower\[/code\]) is already following that user or not.Can anybody help me please?EDIT 2 (based on Mihir Singh's answer)\[code\]$user_follow = dbquery(" SELECT * FROM `user_follow` WHERE `follower` = '$follower' AND `following` = '$following'; ");$check_status = dbrows($user_follow);$sub = false; //Boolean var which states if subscribed or notif ( $check_status !== 0 ){ //Pseudo code $sub = true; //If row is found, they are subscribed, so set $sub to true}if($sub){ $subscribe_status = "follow"; $subscribe_text = "Follow";}else{ $subscribe_status = "unfollow"; $subscribe_text = "Unfollow";}\[/code\]