Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2009
    Location
    Sweden
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    CodeIgniter Help!!

    Hey, I have made a Comment system on my blog, and I would like to make a function that says "No comments yet, be the first!" if there are no rows on a specific post.

    I've tried different ways with num_rows but I'm not sure where to put it or how etc.


    /Please help Tkaeer
    Last edited by Inigoesdr; 02-28-2010 at 08:37 PM. Reason: Marked resolved

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    PHP Code:
    if (mysql_num_rows($query)) == '0') {
    //No comments yet
    }
    else {
    //Comments exist you aren't the first

    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    New Coder
    Join Date
    Dec 2009
    Location
    Sweden
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by masterofollies View Post
    PHP Code:
    if (mysql_num_rows($query)) == '0') {
    //No comments yet
    }
    else {
    //Comments exist you aren't the first

    Thanks for your answer but I fixed it with another solution.

    My solution:
    I put the code directly in my view file, stupid I'm
    PHP Code:
    <?php
    $this
    ->db->where('ID'$this->uri->segment(3));
    $query$this->db->get('comments');
    if(
    $query->num_rows == 0){

    echo 
    "No comments yet, Be the first!";
    }
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •