Seraskier Posted November 18, 2006 Share Posted November 18, 2006 I need to make friends, as in like what is on myspace.com and I was wondering on the best way to do this. Thanks. Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/ Share on other sites More sharing options...
Seraskier Posted November 19, 2006 Author Share Posted November 19, 2006 **bump** Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127059 Share on other sites More sharing options...
rotwyla98 Posted November 19, 2006 Share Posted November 19, 2006 I don't understand... you want to make a site like MySpace? Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127073 Share on other sites More sharing options...
Seraskier Posted November 19, 2006 Author Share Posted November 19, 2006 Yep and i need to know how to do like friends....where you have friends. Its like a myspace but better Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127074 Share on other sites More sharing options...
The Little Guy Posted November 19, 2006 Share Posted November 19, 2006 In your database, make a field, and save all the persons friends id number in there, then when you run the PHP explode the content into an array. Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127090 Share on other sites More sharing options...
Seraskier Posted November 19, 2006 Author Share Posted November 19, 2006 Well would you save each id to a new field or what. Make a new table that has the host id on it, and then what add a field for each friend. Guess that would work. Let me know. Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127158 Share on other sites More sharing options...
Seraskier Posted November 20, 2006 Author Share Posted November 20, 2006 **bump** Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127443 Share on other sites More sharing options...
CheesierAngel Posted November 20, 2006 Share Posted November 20, 2006 I think the best way to achieve this is to create a table in your database named users like:[code]CREATE TABLE users (`userId` int not null auto_increment,`name` varchar(255) not null default '',`address` varchar(255) not null default '',...,PRIMARY KEY (userId));[/code]To Link all the users (as friends) to eachother:[code]CREATE TABLE users_users (`userId` int not null,`friendId` int not null,PRIMARY KEY(userId, friendId));[/code]To find all your friends:[code]SELECT friends.*FROM users_usersINNER JOIN users as `friends` ON friends.userId = users_users.friendIdWHERE users_users.userId = '$MyId'[/code] Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127476 Share on other sites More sharing options...
Seraskier Posted November 20, 2006 Author Share Posted November 20, 2006 thanks, ill work with this. Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127596 Share on other sites More sharing options...
The Little Guy Posted November 20, 2006 Share Posted November 20, 2006 Table- friends tablecolumn names: - user_id- friend_idNow when you do your sql, seach the friends table for where user_id equals the id of the current user. Then get the profile picture of the friend_id with another sql, where user_id equals friend_id from the previous search.Example:[code]<?php$sql = mysql_query("SELECT * FROM friends_table WHERE user_id='$_SESSION[user_id]'")or die(mysql_error());while($row = mysql_fetch_array($sql)){ $sqls = mysql_query("SELECT * FROM users_table WHERE user_id='$row[friend_id]'")or die(mysql_error()); $rows = mysql_fetch_array($sqls); echo $rows[users_display_name];}?>[/code]With this example, you will need to have a session that stores the current users id number (the unique one from the database given at sign up).You will need 2 tables one that has your user, and the one that has friend connections.This is ONLY for displaying of friends.To add/modify/delete friends there are a few more things you will need to do. Link to comment https://forums.phpfreaks.com/topic/27716-friends-like-with-myspace/#findComment-127654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.