Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Somethings wrong in my php function?  (Read 5025 times)

0 Members and 1 Guest are viewing this topic.

Bannana97

    Topic Starter


    Intermediate
  • Owner of HerbertsWorld Corporation
    Somethings wrong in my php function?
    « on: July 22, 2009, 12:55:39 PM »
    The idea:

    I call "GetNumberOfPages(Instance $Number of items)"
    and it returns the number of items I sent it.

    function GetNumOfPages($rows) {
    $max = 5;
    $pgs = $rows;
    $ps = 1;
    $a = 0;
    echo "<!-- while ($pgs > $max) { -->";
    while($pgs > $max) {
    $a++;
    echo "<!-- $a -->";
    if($a == $max) {
    $ps++;
    }
    $pgs = $pgs -1;
    }
    return $ps;
    }
    Thanks
    Bannana97

    Rob Pomeroy



      Prodigy

    • Systems Architect
    • Thanked: 124
      • Me
    • Experience: Expert
    • OS: Other
    Re: Somethings wrong in my php function?
    « Reply #1 on: July 22, 2009, 02:52:35 PM »
    I have no idea what you're trying to do here.  What's all the <!-- --> stuff supposed to be doing?  Is that within <script> tags?
    Only able to visit the forums sporadically, sorry.

    Geek & Dummy - honest news, reviews and howtos

    TechGeek



      Intermediate
    • Thanked: 6
      • Guide to WiFi Optimization
    • Experience: Expert
    • OS: Windows 7
    Re: Somethings wrong in my php function?
    « Reply #2 on: July 31, 2009, 04:23:19 PM »
    The <!-- comment here--->  is for comments in PHP. Nothing will be shown because everything in teh output is a comment. use echo"$ps"; or echo"$a"; without the comment code.
    I help run my home improvement and home automation forum.

    kpac

    • Web moderator
    • Moderator


    • Hacker

    • kpac®
    • Thanked: 184
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: Somethings wrong in my php function?
    « Reply #3 on: August 01, 2009, 04:24:38 AM »
    Quote
    The <!-- comment here--->  is for comments in PHP.
    No, they are HTML comments.

    /*
    This is a block
    of omments
    */

    # One line comment
    // One line comment

    Those are PHP comments.

    TechGeek



      Intermediate
    • Thanked: 6
      • Guide to WiFi Optimization
    • Experience: Expert
    • OS: Windows 7
    Re: Somethings wrong in my php function?
    « Reply #4 on: August 01, 2009, 08:56:13 AM »
    No, they are HTML comments.

    /*
    This is a block
    of omments
    */

    # One line comment
    // One line comment

    Those are PHP comments.
    But since he's using echo those are comments and won't be shown.
    I help run my home improvement and home automation forum.

    Rob Pomeroy



      Prodigy

    • Systems Architect
    • Thanked: 124
      • Me
    • Experience: Expert
    • OS: Other
    Re: Somethings wrong in my php function?
    « Reply #5 on: August 01, 2009, 02:48:49 PM »
    The "while" echoed in the middle of the HTML comment is what's throwing me...
    Only able to visit the forums sporadically, sorry.

    Geek & Dummy - honest news, reviews and howtos