I want to make a contact search engine of those who are your friends only and not others as well as whatsapp does but I do not know how to make a SQL table to make the query.
I passed this code but it does not work for me example:
$SQL_DATA = "SELECT * FROM ".T_USERS." WHERE userID LIKE '%$data_search%' OR userID IN(
SELECT user_one as user_id FROM ".T_FRIENDS." WHERE user_two = $userID UNION
SELECT user_two as user_id FROM ".T_FRIENDS." WHERE user_one = $userID
) ORDER BY userID DESC LIMIT 10";
My tables
CREATE TABLE 'db_user' (
'userID' int(11) NOT NULL,
'user' varchar(170) DEFAULT NULL,
'pass' varchar(255) DEFAULT NULL,
'Wall' varchar(10000) NOT NULL,
'website' varchar(1000) DEFAULT NULL,
'mail' varchar(170) DEFAULT NULL,
'name' varchar(120) DEFAULT NULL,
'sex' varchar(20) DEFAULT NULL,
'vipdate' varchar(25) DEFAULT NULL,
'vip' tinyint(1) DEFAULT NULL,
'banned' tinyint(1) DEFAULT NULL,
'verified' tinyint(1) NOT NULL,
'image' varchar(100) DEFAULT NULL,
'online' varchar(11) DEFAULT NULL,
'time' varchar(25) DEFAULT NULL,
'language' varchar(120) DEFAULT NULL,
'country' varchar(255) DEFAULT NULL,
'day' varchar(11) DEFAULT NULL,
'month' varchar(11) DEFAULT NULL,
'year' varchar(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
table of friends
CREATE TABLE 'db_friends' (
'friend_ID' int(120) NOT NULL,
'user_one' int(120) NOT NULL,
'user_two' int(120) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
$SQL_DATA = '? mysqli code';
$sql = mysqli_query($con,$SQL_DATA) or die ("error en la consulta". mysqli_connect_error());
if (mysqli_num_rows($sql) == 0)
{
echo 'no hay datos';
}else{
echo 'josé';
}