Ok now im gonna get into this a little bit. I am making a new social site kinda thing.
People can input there status like what there doing kinda thing. on the home page after someone logs in it has a section where the user can see there own and there friends status's. Now here is the thing. I have the script search the friends table and get all there friends. My concern about that is what if it grows and say someone has 100 or more friends. Opps that is gonna cause a system lag right?? then then once it has the friends in a normal single array it goes and grabs all the status up to LIMIT 0,15 per friend through the status's table. mysql. and then im thinking another system strain right. anyways it puts all the info into a Multi Deminsional array. Then it is sorted by time. then outputs it. How can i make it stop at say 50 status on output. I put my code in here and maybe you can see what i have done and what i can do. Can i use a union? if so how?
echo "<br><small><center>Viewing All Friends Status's</center></small><hr>";
$zoneid = "$loggedin";
$result = mysql_query("SELECT * FROM friendtable WHERE ownerid='$loggedin' AND confirmed='1'");
while($row = mysql_fetch_array($result)) {
$dazoneid = $row['friendid'];
$friendarray[] = $dazoneid;
}
foreach($friendarray as $key => $value) {
$result = mysql_query("SELECT * FROM zonestatus WHERE userid='$value' ORDER BY `rawtime` DESC LIMIT 0, 15");
while($row = mysql_fetch_array($result)) {
$dazoneid = $row['id'];
$dazoneuserid = $row['userid'];
$darawtime = $row['rawtime'];
$dazonestatus = $row['status'];
$superman[] = array("dazoneid" => $dazoneid, "dazoneuserid" => $dazoneuserid, "darawtime" => $darawtime, "dazonestatus" => $dazonestatus);
}
}
$result = mysql_query("SELECT * FROM zonestatus WHERE userid='$loggedin' ORDER BY `rawtime` DESC LIMIT 0, 15");
while($row = mysql_fetch_array($result)) {
$dazoneid = $row['id'];
$dazoneuserid = $row['userid'];
$darawtime = $row['rawtime'];
$dazonestatus = $row['status'];
$superman[] = array("dazoneid" => $dazoneid, "dazoneuserid" => $dazoneuserid, "darawtime" => $darawtime, "dazonestatus" => $dazonestatus);
}
// Pass the array, followed by the column names and sort flags
$superman = array_orderby($superman, 'darawtime', SORT_DESC);
foreach($superman as $key => $value) {
$itsid = $superman[$key]['dazoneid'];
$itsuserid = $superman[$key]['dazoneuserid'];
$itsrawtime = $superman[$key]['darawtime'];
$itsstatus = $superman[$key]['dazonestatus'];
$userdisplayname = getuserdisplayname("$itsuserid", 'displayname');
$itsprofilepic = getprofilepic($itsuserid, '50', 'thumbs');
echo "<table border='0' width='100%'><tr>";
echo "<td valign='top' width='55'>$itsprofilepic</td>";
echo "<td valign='top' align='left'>
<a href='callfile.php?modname=profile&fileid=profile&callid=$itsuserid'>$userdisplayname</a>
$itsstatus <br>";
$cooltime = time();
$difference = $cooltime - $itsrawtime;
if ($difference < 60) {
$timeleft = $difference . " seconds ago";
} else {
$difference = round($difference / 60);
if ($difference < 60)
$timeleft = $difference . " minutes ago";
else {
$difference = round($difference / 60);
if ($difference < 24)
$timeleft = $difference . " hours ago";
else {
$difference = round($difference / 24);
if ($difference < 7)
$timeleft = $difference . " days ago";
}
}
}
echo "<small>Left on :: " . date('m/d/Y h:m:a', $itsrawtime) . " | $timeleft </small>";
echo "</td>";
echo "</tr></table><hr>";
}