![]() |
Having trobles with data from DB - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Having trobles with data from DB (/showthread.php?tid=71284) |
Having trobles with data from DB - kirasiris - 07-27-2018 I currently have this code in my controller: PHP Code: public function profile($username){ and this in my model: PHP Code: // Relationship for single and this is my view: PHP Code: <?php if($item->username == $this->session->username) : ?> The problem is when there is not existing relationship(friendship). Let's say when I visit a user which is already my friend, it shows me the proper button "the unfollow"(friendship; status: accepted) and it shows the proper button as well when the friendship is in status: pending. Now when I visit a user which is not my friend(when there's not friendship), it should display the last button which is the follow button but the current output is an error of "error handler" Can somebody tell me where is my error? RE: Having trobles with data from DB - php_rocs - 07-27-2018 @kirasiris, What value is relationship when the error is thrown? Also, any reason why you didn't use switch condition instead of if_then_else condition? RE: Having trobles with data from DB - dave friend - 07-27-2018 It is not clear exactly when is the error thrown. Is it as the not-friend profile displays or after you try to "follow" them? What error message is shown? RE: Having trobles with data from DB - dave friend - 07-27-2018 Do you know that, in the view, the first if() block has no code to execute? Also, you do not need to use PHP opening and closing tags on every statement. Unless you want to leave the PHP processor to output HTML directly you only need the PHP opening tag. If all the superfluous PHP tags are removed you get this, much easier to read code. PHP Code: <?php Hopefully, it is now clear the first if() is followed by elseif() without code (except for the comment) in between the two. |