Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Help With Code

  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default Help With Code

    Well the code is below:
    PHP Code:
    <?

    include "config.php";

    $d mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
    while (
    $staff mysql_fetch_array($d)) {
    IF (
    $staff[level] == 2) {

    echo (
    " <p><strong></strong></p> ");

    echo (
    "

    <p><a href=\"members.php?view=Profile&user=
    $staff[username]\"><b>$staff[habboname]</b></a> - DJ $staff[username]");

    }

    }
    ?>
    But it adds users in rows like

    Link
    Link
    Link

    Does any one know how to make them in collums (of 3)?
    Like

    Link Link Link

    + Rep For Helping

    J1MI (Forum Moderator) - Thread moved from Website designing, hopefully you'll get more reply's here
    Last edited by J1MI; 29-11-2006 at 05:25 PM.

  2. #2
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Each loop have a value increment ($i++) and use
    PHP Code:
    if ($i == $i == $i == 9) {} 
    etc etc.

    Obviously if it returns true, <br /> or new table row, whatever method you're using.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  3. #3
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Heinous View Post
    Each loop have a value increment ($i++) and use
    PHP Code:
    if ($i == $i == $i == 9) {} 
    etc etc.

    Obviously if it returns true, <br /> or new table row, whatever method you're using.
    Can u edit the code above please :p
    Im not very good when people say use this, I then end up staring at screen like, erm, hum, where I put it lol

  4. #4
    Join Date
    Mar 2005
    Location
    Leeds
    Posts
    3,423
    Tokens
    0

    Latest Awards:

    Default

    Its much easier to do it this way...

    PHP Code:
    <?

    include "config.php";

    $d mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
    while (
    $staff mysql_fetch_array($d)) {
    IF (
    $staff[level] == 2) {

    echo (
    " <p><strong></strong></p> ");

    echo (
    "

    <div style=\"width: 33%;\"><a href=\"members.php?view=Profile&user=
    $staff[username]\"><b>$staff[habboname]</b></a> - DJ $staff[username]</div>");

    }

    }
    ?>
    Make each div 33%
    Last edited by Luckyrare; 28-11-2006 at 09:12 PM.

  5. #5
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Quote Originally Posted by Luckyrare View Post
    Its much easier to do it this way...

    PHP Code:
    <?

    include "config.php";

    $d mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");
    while (
    $staff mysql_fetch_array($d)) {
    IF (
    $staff[level] == 2) {

    echo (
    " <p><strong></strong></p> ");

    echo (
    "

    <div style=\"width: 33%;\"><a href=\"members.php?view=Profile&user=
    $staff[username]\"><b>$staff[habboname]</b></a> - DJ $staff[username]</div>");

    }

    }
    ?>
    Make each div 33%
    But darling, div's stack by default. And if he used float, then that would stuff up as it would be floating.

    And no, you asked for help, I told you how. If you don't work out how to implement it yourself, you'll never learn.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  6. #6
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    didnt work :S

  7. #7
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    put $i = 0; before the while statement. :p

    edit;
    and $i = $i++ in the while statement.
    Last edited by Heinous; 28-11-2006 at 09:48 PM.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  8. #8
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Im Officaly Confused Now :S

  9. #9
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <table border="1">

    <?php

     
    require('config.php');

     
    $SQL mysql_query("SELECT * FROM `users` ORDER BY `level` ASC");

     while(
    $row mysql_fetch_array($SQL)) 
     {
       if(!
    $n) print '<tr>';
       
    $n++;
       print <<<HTML
       <td> <a href='members.php?view=Profile&user={$row['username']}'>{$row['habboname']}</a> - {$row['username']} </td>
    HTML;
       if(
    $n!=3) continue;
       print 
    '</tr>';
       unset(
    $n);
     } 

    ?>

    </table>
    kinda quit.

  10. #10
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Heinous View Post
    put $i = 0; before the while statement. :p

    edit;
    and $i = $i++ in the while statement.
    Im to lazy to follow whats going on here but, you dont actualy need the $i = part. The code $i++ on its own is all you need to incriment the value of $i by one

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
  •