Member Avatar for Aardwolf

I have 3 MySQL database
1 is friends, 1 is dashboard and 1 is user
what i want is to do a recurrng loop to display all of dashboard, except if you are friends with them.

I have this:

$queryy = mysql_query("SELECT * FROM dashboard ORDER BY time DESC LIMIT $show");
			  
			  while($friendid = mysql_fetch_array($queryy)){
				  $friendidi = $friendid['userid'];
					$friendquery = mysql_query("SELECT * FROM friends WHERE friendid = '".$friendidi."' AND accepted = '1'");
				while($friendss = mysql_fetch_array($friendquery)) {
					
					$queryy2 = mysql_query("SELECT * FROM dissusers WHERE ID = '".$friendidi."'");
				   while($wallposter = mysql_fetch_array($queryy2)){
//recurring loop, only shows if you are friends.
}
}
}

I recommend using classes and objects and build up what a 'user' and friend are, and pass the data back and forth between classes. That is some intense querying from the page you are going to kill your site.
if you send me your dashboard, friends and dissusers table structures perhaps I could show you the way if you are interested in learning.

Member Avatar for Aardwolf

dashboard:

CREATE TABLE IF NOT EXISTS `dashboard` (
  `ID` mediumint(9) NOT NULL AUTO_INCREMENT,
  `userid` varchar(60) NOT NULL,
  `message` text NOT NULL,
  `time` varchar(60) NOT NULL,
  PRIMARY KEY (`ID`)
)

users:

CREATE TABLE IF NOT EXISTS `dissusers` (
  `ID` mediumint(9) NOT NULL AUTO_INCREMENT,
  `FirstName` varchar(60) NOT NULL,
  `LastName` varchar(60) NOT NULL,
  `username` varchar(60) DEFAULT NULL,
  `password` varchar(60) DEFAULT NULL,
  `resetPassword` varchar(60) NOT NULL,
  `email` varchar(60) NOT NULL,
  `about` text NOT NULL,
  `activationcode` varchar(60) NOT NULL DEFAULT '',
  `activated` varchar(60) NOT NULL DEFAULT '0',
  `DPpath` varchar(120) NOT NULL,
  `inbox` varchar(60) NOT NULL,
  `inboxunread` varchar(60) NOT NULL DEFAULT '0',
  `notification` varchar(60) NOT NULL,
  `notificationunread` varchar(60) NOT NULL DEFAULT '0',
  `FirstTime` varchar(60) NOT NULL,
  `IP` varchar(60) NOT NULL,
  `betatester` varchar(60) NOT NULL,
  `rightsPosition` varchar(60) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
)

friends:

CREATE TABLE IF NOT EXISTS `friends` (
  `ID` mediumint(9) NOT NULL AUTO_INCREMENT,
  `userid` varchar(60) NOT NULL,
  `friendid` varchar(60) NOT NULL,
  `accepted` varchar(60) NOT NULL,
  `friendaccept` varchar(60) NOT NULL,
  PRIMARY KEY (`ID`)
)

what is your goal, how do these three objects relate to each other? Your current query looks like it pulls the whole dashboard, which (appears) that would be everybody, and then you try to loop through friends and dissusers. do you want to pull the whole dashboard everytime or specific for an userid. how does dissusers relate to friends table. it looks like dissusers is your main object and they can have friends and they can have a dashboard. on the dashboard do you want to display all friends and pull friends data from dissusers... thats what I am seeing. please give some feedback and I will give you an example of code to do what you want.

He wants to make a social networking site.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.