Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1

    Default PHP Help Request

    Hello Guys!

    I am after a little help,

    I am setting up a user-system with RMB's user-system as i quite like it,
    Now i know their is security flaws and what not, But I'll sort them out.

    It's been doing my head in trying to get this to work but i would like to
    know if you could recode this to make the member list showup like this:

    Userlist:

    [MemberName] [MemberName] [MemberName]

    [MemberName] [MemberName] [MemberName]

    But Currently it's showing up like:

    [MemberName]
    [MemberName]
    [MemberName]
    [MemberName]
    [MemberName]

    Etc..

    Here is the code:

    PHP Code:
    }
    }else{
    //gets all the members from the database
    $getusers mysql_query("SELECT * FROM `authme` ORDER BY `id` ASC") or die(mysql_error());
    //loops there name out
    while ($user mysql_fetch_array($getusers)) {
    echo 
    "<a href='members.php?user=$user[username]'>$user[username]</a><br>";
    }
    }
    echo 
    "<center>";
    ?> 
    Would be appreciated if you could help me with this asap.

    Thanks,
    Chris.
    Thank-you,
    Christopher Holland

  2. #2
    Join Date
    Jun 2005
    Location
    /dev/null
    Posts
    4,918
    Tokens
    126

    Latest Awards:

    Default

    A little bit messy and untested, but something like this should work.
    PHP Code:
    }
    }else{
    //gets all the members from the database
    $getusers mysql_query("SELECT * FROM `authme` ORDER BY `id` ASC") or die(mysql_error());
    //loops there name out
    $i 1;
    while (
    $user mysql_fetch_array($getusers)) {
    if (
    $i != 0) {
    echo 
    "<a href=\"members.php?user={$user['username']}\">{$user['username']}</a> ";
    } else {
    echo 
    "<a href=\"members.php?user={$user['username']}\">{$user['username']}</a><br />";
    }
    i++;
    }
    }
    echo 
    "<center>";
    ?> 
    Last edited by N!ck; 01-04-2012 at 12:43 PM.

  3. #3

    Default

    Cheer's for that mate, Ill check it about asap.
    Thank-you,
    Christopher Holland

  4. #4

    Default

    Ok so that did work, but it didn't

    I was after it to display diffrent users name's 3 across so on,
    but the script you sent displays as many as it can fit on the page across.

    Could you posiblly re-design the code to do this?

    [Username1] [Username2] [Username3]
    [Username4] [Username5] [Username6]
    So on..

    In tables?
    Thank-you,
    Christopher Holland

  5. #5
    Join Date
    Oct 2011
    Location
    Melbourne
    Posts
    637
    Tokens
    1,376

    Default

    Okay this is pseudocode since I'm not on a Pc!


    while($i < 3){
    ..if($i == 3){
    ....echo "<tr><td>username</td></tr>"
    ....$i=0
    ..} else {
    ....echo "<td>username</td>
    ..}
    ..$i ++
    }

  6. #6

    Default

    Quote Originally Posted by Blinger View Post
    Okay this is pseudocode since I'm not on a Pc!


    while($i < 3){
    ..if($i == 3){
    ....echo "<tr><td>username</td></tr>"
    ....$i=0
    ..} else {
    ....echo "<td>username</td>
    ..}
    ..$i ++
    }

    So ill just remove the ..?
    Thank-you,
    Christopher Holland

  7. #7
    Join Date
    Oct 2011
    Location
    Melbourne
    Posts
    637
    Tokens
    1,376

    Default

    Ill jump on a Pc now and type up what should work!

    ---------- Post added 06-04-2012 at 04:03 PM ----------

    PHP Code:
    } else {
    // row counter
    $i 0;
    // Echo the start of the table
    echo("<table width=\"90%\" border=\"0\"><tr>");
    // Start fetching usernames
    while ($user mysql_fetch_array($getusers)) {
        
    // Check whether we are at the 3rd member
        
    if($i 3){
            
    // Since we are, echo start of a new row
            
    echo("</tr><tr>");
        }
        
    // Show the users
        
    echo ("<td width=\"33%\" align=\"center\"><a href=\"members.php?user={$user['username']}\">{$user['username']}</a></td>");
    }
    // End of the table and users
    echo("</tr></table>"); 
    That should work

  8. #8

    Default

    Quote Originally Posted by Blinger View Post
    Ill jump on a Pc now and type up what should work!

    ---------- Post added 06-04-2012 at 04:03 PM ----------

    PHP Code:
    } else {
    // row counter
    $i 0;
    // Echo the start of the table
    echo("<table width=\"90%\" border=\"0\"><tr>");
    // Start fetching usernames
    while ($user mysql_fetch_array($getusers)) {
        
    // Check whether we are at the 3rd member
        
    if($i 3){
            
    // Since we are, echo start of a new row
            
    echo("</tr><tr>");
        }
        
    // Show the users
        
    echo ("<td width=\"33%\" align=\"center\"><a href=\"members.php?user={$user['username']}\">{$user['username']}</a></td>");
    }
    // End of the table and users
    echo("</tr></table>"); 
    That should work
    OK so i have this:


    PHP Code:
    ";

    }
    }else{
    //gets all the members from the database
    $getusers = mysql_query("SELECT FROM `authmeORDER BY `idASC") or die(mysql_error());
    //loops there name out
    while (
    $user = mysql_fetch_array($getusers)) {
    // row counter
    $i = 0;
    // Echo the start of the table
    echo("
    <table width=\"90%\" border=\"0\"><tr>");
    // Start fetching usernames
    while ($user mysql_fetch_array($getusers)) {
        
    // Check whether we are at the 3rd member
        
    if($i 3){
            
    // Since we are, echo start of a new row
            
    echo("</tr><tr>");
        }
        
    // Show the users
        
    echo ("<td width=\"33%\" align=\"center\"><a href=\"members.php?user={$user['username']}\">{$user['username']}</a></td>");
    }
    // End of the table and users
    echo("</tr></table>");  
    echo(
    "");  
    ?> 
    And it's showing it back to this format?
    {member}

    {member}

    {member}

    {member}

    {member}

    {member}
    Last edited by ChristopherH; 06-04-2012 at 06:36 AM.
    Thank-you,
    Christopher Holland

  9. #9
    Join Date
    Oct 2011
    Location
    Melbourne
    Posts
    637
    Tokens
    1,376

    Default

    You need to close the while loop.

  10. #10

    Default

    Hahah I'm really ****** at this kind of stuff Blinger
    Would love it if you could help me with that one?
    Thank-you,
    Christopher Holland

Page 1 of 2 12 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
  •