davidb52 Posted September 5, 2011 Share Posted September 5, 2011 First of al sorry for bad english,Hi,I'm trying to make a blog system and show you own blogs and friend blogs.this is my 'database'1. usersf> id (you) and friends (friends)2. blog> id(anyone but i want to select my own and friends)This is what I did: $query = mysql_query("SELECT friends FROM dabosn.usersf WHERE id='" . mysql_real_escape_string( $id ) . "'");while($row = mysql_fetch_assoc($query)){$friends = $row['friends'];}echo $friends;$query = mysql_query("SELECT b.bid,b.id,b.title,b.blog,b.picture,b.video,b.blogsize,u.easyname FROM blog as b,dabosn.users as u WHERE u.id=b.id and b.id='" . mysql_real_escape_string( $friends ) . "'");while($row2 = mysql_fetch_assoc($query)){echo $row2['easyname'];}Only that doesn't work because {} stops before the other query: $query = mysql_query("SELECT friends FROM dabosn.usersf WHERE id='" . mysql_real_escape_string( $id ) . "'");while($row = mysql_fetch_assoc($query)){$friends = $row['friends'];echo $friends;$query = mysql_query("SELECT b.bid,b.id,b.title,b.blog,b.picture,b.video,b.blogsize,u.easyname FROM blog as b,dabosn.users as u WHERE u.id=b.id and b.id='" . mysql_real_escape_string( $friends ) . "'");while($row2 = mysql_fetch_assoc($query)){echo $row2['easyname'];}}Normally this works but now it only show 1 friendso I tried 1 query $query = mysql_query("SELECT b.bid,b.id,b.title,b.blog,b.picture,b.video,b.blogsize,u.easyname FROM blog as b,dabosn.users as u,dabosn.usersf as f WHERE u.id=b.id and b.id=f.friends(WHERE f.id=mine $id )";while($row2 = mysql_fetch_assoc($query)){echo $row2['easyname'];}}Ofcourse this not going to work but how do i make something like this? that between the ()And this only shows friends how do i add my own message to? i was thinking add or b.id=$id is that going to work?Already thanks! Link to comment Share on other sites More sharing options...
davidb52 Posted September 5, 2011 Author Share Posted September 5, 2011 already found out:$query = mysql_query("SELECT b.bid,b.id,b.title,b.blog,b.picture,b.video,u.easyname FROM blog as b,dabosn.users as u,dabosn.usersf as f WHERE u.id=b.id and '" . mysql_real_escape_string( $id ) . "'=f.id and f.friends=b.id ORDER BY dbdate DESC");and make in usersfid friendsmyid myid Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.