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.
Page 1 of 8 123 ... LastLast
Results 1 to 15 of 115

Thread: Row Counter

  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts

    Row Counter

    Hello, I have made this row counter and would like some help, I would like to align the output to the right side of the screen and infront of the numbers add
    'Number of Members:'

    Here is the script:
    PHP Code:
    $result mysql_query("select count(*) as rowcount from notes");
    $row mysql_fetch_array($result);
    echo 
    $row['rowcount']; 
    I think the echo needs to be written differently.

  • #2
    New Coder
    Join Date
    Aug 2009
    Posts
    76
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Hmm interesting I think I might have a solution for you. If I find it I will edit this post.

  • #3
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    You do not off the top of your head?

  • #4
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    I think I have gotten it:

    PHP Code:
    <?php
    $result 
    mysql_query("select count(*) as rowcount from notes");
    $Count mysql_result($result0);
    echo 
    "Number of Members: $Count";
    ?>
    All I need to do is align it to the right.

  • #5
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    PHP Code:
    $result mysql_query("select count(*) as rowcount from notes");
    $row mysql_fetch_array($result);
    echo 
    "Number of members: " $row['rowcount']; 
    the period (.) is a concatenation symbol, which means it is used to combine different things into one string.

    Edit: as far as alignment goes, do that with HTML/CSS


    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #6
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    $query mysql_query("SELECT * from `notes` order by id");
    $num mysql_num_rows($query); 

  • #7
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Now it seems to not be showing up at all

    PHP Code:
    <?php
    $result 
    mysql_query("select count(*) as rowcount from notes");
    $Count mysql_result($result0);
    echo 
    "<span style=\"text-align:right\">" $row['rowcount'] . "</span>";
    ?>

  • #8
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Change $row['rowcount'] to $Count.

    because you're using $Count = mysql_result($result, 0); instead of $row = mysql_fetch_array($result);

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #9
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Hm.. still nothing, this is the updated code:

    PHP Code:
    <?php
    $result 
    mysql_query("select count(*) as rowcount from notes");
    $Count mysql_result($result0);
    echo 
    "<span style=\"text-align:right\">"$Count"</span>";
    ?>

  • #10
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    <?php
    $result 
    mysql_query("select count(*) as rowcount from notes");
    $Count mysql_result($result0);
    echo 
    "<span style=\"text-align:right\">".$Count."</span>";
    ?>

  • #11
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    $query mysql_query("SELECT * from `notes` order by id");
    $num mysql_num_rows($query);
    echo 
    "<span style=\"text-align:right\">".$num."</span>"

  • #12
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Nothing is still showing up.

    This little code is giving so much pain to me and you guys.

  • #13
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Show us the current code.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #14
    Regular Coder
    Join Date
    Sep 2008
    Posts
    697
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Ok 1 moment.
    PHP Code:
    $query mysql_query("SELECT * from `notes` order by id");
    $num mysql_num_rows($query);
    echo 
    "<span style=\"text-align:right\">".$num."</span>"

  • #15
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    $query = mysql_query("SELECT * from `notes` order by id") or die(mysql_error());
    $num = mysql_num_rows($query);
    echo "<span style=\"text-align:right\">".$num."</span>";

    That will give a MySQL error if there is one.

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  
    Page 1 of 8 123 ... LastLast

    Posting Permissions

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