everlifefree Posted March 3, 2008 Share Posted March 3, 2008 Ok I have 2 areas that display but only one works to show it the events work but the bulletins doesn't yet if I switch it so that the events is drawing info for the bulletin from the mysql then the bulletins will work in the events area and the events won't work in the bulletins area I was wondering if some one would be kind enough to review my php code and let me know what I did wrong. Php code involved in getting events and bulletins // NEXT X EVENTS ////////////////////////////////////////////////////////////////// /* Select the next 5 events */ $nextEventsSelect = myQ(" SELECT `id`,`date`,`title` FROM `[x]events` WHERE ( (`display`='private' AND `user`='".me("id")."') OR (`display`='shared' AND ($contacts `user`='".me("id")."' )) OR (`display`='public') OR (`display`='system') ) AND `date` > '".date("U")."' ORDER BY `date` ASC LIMIT 5 "); /* Loop in the results, create the looping array */ $i=0; while ($nextEventRow = myF($nextEventsSelect)) { $nextEventsReplacementArray[$i]["event.title"] = _fnc("strtrim", $nextEventRow["title"], 30); $nextEventsReplacementArray[$i]["event.date"] = date($CONF["LOCALE_SHORT_DATE"], $nextEventRow["date"]); $nextEventsReplacementArray[$i]["event.id"] = $nextEventRow["id"]; $i++; } /* Assign the array to the loop engine */ if (isset($nextEventsReplacementArray)) $tpl->Loop("nextEvents", $nextEventsReplacementArray); if (isset($nextEventsReplacementArray)) {$tpl -> Zone("hasContact", "gotEvent");} if (!isset($nextEventsReplacementArray)) {$tpl -> Zone("hasContact", "noEvent");} // NEXT X BULLETINS ////////////////////////////////////////////////////////////////// /* Select the next 5 bulletins */ $nextBulletinsSelect = myQ(" SELECT `id`,`username`,`title`,`date` FROM `[x]bulletins` WHERE ( (`display`='private' AND `user`='".me("id")."') OR (`display`='shared' AND ($contacts `user`='".me("id")."' )) OR (`display`='public') OR (`display`='system') ) AND `date` > '".date("U")."' ORDER BY `date` ASC LIMIT 5 "); /* Loop in the results, create the looping array */ $i=0; while ($nextBulletinRow = myF($nextBulletinsSelect)) { $nextBulletinsReplacementArray[$i]["bulletin.title"] = _fnc("strtrim", $nextBulletinRow["title"], 30); $nextBulletinsReplacementArray[$i]["bulletin.username"] = $nextBulletinRow["username"]; $nextBulletinsReplacementArray[$i]["bulletin.date"] = date($CONF["LOCALE_SHORT_DATE"], $nextBulletinRow["date"]); $nextBulletinsReplacementArray[$i]["bulletin.id"] = $nextBulletinRow["id"]; $i++; } /* Assign the array to the loop engine */ if (isset($nextBulletinsReplacementArray)) $tpl->Loop("nextBulletins", $nextBulletinsReplacementArray); if (isset($nextBulletinsReplacementArray)) {$tpl -> Zone("hasContacts", "gotBulletin");} if (!isset($nextBulletinsReplacementArray)) {$tpl -> Zone("hasContacts", "noBulletin");} This code is used in both of them to display the event to contact of the user if the submitter only wanted his contacts to see it (used entirely on bulletin and a little on events works fine with the events side of thing... $userContactsArray = unpk(me("contacts")); $i=0; /* We will only act if the usercontactsarray is ... an array! If it is, start looping! */ if (is_array($userContactsArray)) foreach($userContactsArray as $userContactGroup => $contactsUsersArray) { /* Loop in the users array if it is an array */ if (is_array($contactsUsersArray)) foreach($contactsUsersArray as $contactsUserID) { /* Now things starts being tricky -- We will get the third party user contacts array and verity that this user is also in the other user's contacts ... If both are in a relationship, we will show that user on the profile page */ $thirdUserContactsArray = unpk(_fnc("user", $contactsUserID, "contacts")); /* if it's an array, and that the user is in... */ if (is_array($thirdUserContactsArray) && _fnc("in_multiarray", $thirdUserContactsArray, me("id"))) { /* If "i" is zero, it means this is the first successful cycle, we will enable the contact tab in the template. */ if ($i==0) $tpl->Zone("contactsTab", "enabled"); /* Generate this entity' entry in the contacts array. */ $contactEntityArray[$i]["contact.id"] = $contactsUserID; $contacts = $contacts . "`user`='" . $contactsUserID . "'" . " OR "; $i++; } } } Quote Link to comment https://forums.phpfreaks.com/topic/94110-display-issues/ Share on other sites More sharing options...
everlifefree Posted March 3, 2008 Author Share Posted March 3, 2008 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/94110-display-issues/#findComment-482187 Share on other sites More sharing options...
everlifefree Posted March 3, 2008 Author Share Posted March 3, 2008 help Quote Link to comment https://forums.phpfreaks.com/topic/94110-display-issues/#findComment-482391 Share on other sites More sharing options...
everlifefree Posted March 4, 2008 Author Share Posted March 4, 2008 Still need help! Quote Link to comment https://forums.phpfreaks.com/topic/94110-display-issues/#findComment-483327 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.