danjapro Posted March 12, 2011 Share Posted March 12, 2011 I am ok with codeing but NOT half-as good as some of your GUYS here. I'm trying to write a simple sql query based on returning certain values from a table for that user. I would like to just beable to include this as a page user.info.php and render it on any page as include to return need values . See My CODE. PLESE HELP ME. <?php @session_start(); $user = $_SESSION['username']; // Set cookie $userid = JRequest::getVar('userid'); $data = new stdClass(); $model =& $this->getModel('profile'); $my = CFactory::getUser(); // Test if userid is 0, check if the user is viewing its own profile. $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $userId = $user->id; // Return with empty data if($userId == null || $userId == '') { //return false; } $user =& JFactory::getUser($userId); if($user->id == null){ //return false; } $id = & JFactory::getUser($userId); $query = 'SELECT user_id, id, format_id, year, name FROM #__muscol_albums WHERE user_id = ' . $id; //$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ; $result = mysql_query($query) or die('Error, No Album Search failed'); list($name, $user_id, $id, $year) = mysql_fetch_array($result); echo $id; echo $user_id; echo $year; // preform id return check and redirecto to correct url if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')){ $url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1'; } else { $url=JURI::root().'index.php?option=com_community&view=profile&id=1&tmpl=component&print=1'; //redirect is a function } ?> Quote Link to comment 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.