UPDATE db_friends SET friends = concat(friends,',','{friend:$friend,relationship:none}') WHERE login='$login'
SELECT * FROM db_friends WHERE login = '$login' AND friends LIKE ('{%friend:$friend%}')
<?php
require_once('../include/dbconnect.php');
//$login = @$_POST['amp;login'];
//$friend = @$_POST['amp;friend'];
$login = $_GET['login'];
$friend = $_GET['friend'];
$result = mysql_query("SELECT * FROM db_friends WHERE login = '$login'");
if(mysql_num_rows($result) == 0){
mysql_query("INSERT INTO db_friends (login) VALUES ('$login')");
}
$result1=mysql_query("SELECT * FROM db_friends WHERE login = '$login' AND friends LIKE ('{%friend:$friend%}')");
if(mysql_num_rows($result1) == 0){
echo('thereisno ');
if(mysql_num_rows(mysql_query("SELECT * FROM db_friends WHERE num = 0"))>0){
mysql_query("UPDATE db_friends SET friends = concat(friends,'{friend:$friend,relation:none}') WHERE login='$login'");
}else{
mysql_query("UPDATE db_friends SET friends = concat(friends,',','{friend:$friend,relation:none}') WHERE login='$login'");
}
mysql_query("UPDATE db_friends SET num=num+1 WHERE login='$login'");
}
echo($friend." ".$login);
?>