Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Mysql help/PHP

  1. #1
    Join Date
    Nov 2007
    Posts
    182
    Tokens
    0

    Default Mysql help/PHP



    Is there anyway to make the rares be grabbed in order of there value?

  2. #2
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Do you think your code could get any messier? I mean seriously.. have you never heard of indention?

    Change your $get_rares query to this..

    PHP Code:
    $get_rares mysql_query"SELECT * FROM `rares` WHERE `catid`='{$cats ['id']}' ORDER BY `value` DESC" ) or die( mysql_error() ); 
    Should work.

  3. #3
    Join Date
    Nov 2007
    Posts
    182
    Tokens
    0

    Default

    Quote Originally Posted by Dentafrice View Post
    Do you think your code could get any messier? I mean seriously.. have you never heard of indention?

    Change your $get_rares query to this..

    PHP Code:
    $get_rares mysql_query"SELECT * FROM `rares` WHERE `catid`='{$cats ['id']}' ORDER BY `value` DESC" ) or die( mysql_error() ); 
    Should work.
    This was very helpful and got some kind of result, Only problem is its now ordering them by there first number

    so kind of like

    99 9 84 6 54

    any ideas?, and thanks

  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    What do you mean it is ordering them by their first number? Tad bit confused there ;P

  5. #5
    Join Date
    Nov 2007
    Posts
    182
    Tokens
    0

    Default

    like it will go

    94
    93
    9
    84
    7
    64

    if you get me

    also...

    www.habtopia.co.uk/values/show_rares.php should help you get what i mean

  6. #6
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    So really you want to order them by their minimal value to highest value or visa versa?
    Back for a while.

  7. #7
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    I thought you wanted them in descending order (greatest to lowest).

    If you want them to go:

    90, 80, 70, 60, 50:

    PHP Code:
    $get_rares mysql_query"SELECT * FROM `rares` WHERE `catid`='{$cats ['id']}' ORDER BY `value` DESC" ) or die( mysql_error() ); 
    If you want them to go:

    20, 30, 40, 50, 60

    PHP Code:
    $get_rares mysql_query"SELECT * FROM `rares` WHERE `catid`='{$cats ['id']}' ORDER BY `value` ASC" ) or die( mysql_error() ); 

  8. #8
    Join Date
    Nov 2007
    Posts
    182
    Tokens
    0

    Default

    Still ordering them the same weird :S

    <?php
    include("config.php");
    include("opendb.php");
    $get_cats = mysql_query("SELECT * FROM `categories` ORDER BY `displayorder`") or die(mysql_error());
    $get_info = mysql_query("SELECT * FROM `systeminfo`") or die(mysql_error());
    $info = mysql_fetch_array($get_info);
    while($cats = mysql_fetch_array($get_cats)) {
    $get_rares = mysql_query( "SELECT * FROM `rares` WHERE `catid`='{$cats ['id']}' ORDER BY `value` DESC" ) or die( mysql_error() );
    echo("<b><center><font face=verdana size=1> &nbsp; &nbsp;".$cats['name']."</font></center></b><br>
    <table width=\"466\" border=\"0\">
    ");
    $color1 = $info[stripe1];
    $color2 = $info[stripe2];
    $row_count = 0;
    while($rare = mysql_fetch_array($get_rares)) {
    $row_color = ($row_count % 2) ? $color1 : $color2;
    ?>
    <td>
    <td width="15%" style="text-align:center;background-color:#<?php echo $row_color; ?>"><font face=verdana size=1><?php echo $rare['name']; ?></font><br><font face=verdana size=1><img alt="" src="<?php echo("".$info[imagepath]."".$rare['image'].""); ?>"><br><?php echo $rare['value']; ?> HC</font></td>
    </td>
    <?php
    $row_count++;
    if($row_count==6){
    echo '</tr><tr>'; //close and open a row if $row_count=;6
    $row_count=0;
    }
    }
    echo("</table><br>
    ");
    }
    ?>
    www.habtopia.co.uk/values/show_rares.php
    Last edited by Habtopia; 20-12-2008 at 02:59 PM.

  9. #9
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Okay try this.. we'll see what it's doing and I'll help you figure it out..

    try this code.. save it and upload it.. then tell me and I'll look..

    PHP Code:
    <?php
    include ("config.php");
    include (
    "opendb.php");
    $get_cats mysql_query"SELECT * FROM `categories` ORDER BY `displayorder`" ) or die( mysql_error() );
    $get_info mysql_query"SELECT * FROM `systeminfo`" ) or die( mysql_error() );
    $info mysql_fetch_array$get_info );
    while( 
    $cats mysql_fetch_array$get_cats ) ) {
        
    $get_rares mysql_query"SELECT * FROM `rares` WHERE `catid`='{$cats ['id']}' ORDER BY `value` DESC" ) or die( mysql_error() );
        echo (
    "<b><center><font face=verdana size=1> &nbsp; &nbsp;" $cats ['name'] . "</font></center></b><br>
    <table width=\"466\" border=\"0\">
    "
    );
        
    $color1 $info [stripe1];
        
    $color2 $info [stripe2];
        
    $row_count 0;
        while( 
    $rare mysql_fetch_array$get_rares ) ) {
            
    $row_color = ($row_count 2) ? $color1 $color2;
            
    ?>
    <td>
    <td id="<?php
            
    echo $rare ["id"];
            
    ?>" width="15%" style="text-align:center;background-color:#<?php
            
    echo $row_color;
            
    ?>"><font face=verdana size=1><?php
            
    echo $rare ['name'];
            
    ?></font><br>
    <font face=verdana size=1><img alt=""
        src="<?php
            
    echo ("" $info [imagepath] . "" $rare ['image'] . "");
            
    ?>"><br><?php
            
    echo $rare ['value'];
            
    ?> HC</font></td>
    </td>
    <?php
            $row_count 
    ++;
            if(
    $row_count == 6) {
                echo 
    '</tr><tr>'//close and open a row if $row_count=;6
                
    $row_count 0;
            }
        }
        echo (
    "</table><br>
    "
    );
    }
    ?>

  10. #10
    Join Date
    Nov 2007
    Posts
    182
    Tokens
    0

    Default

    its there on www.habtopia.co.uk/values/show_rares.php

    and thanks for help so far

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