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 29
  1. #1
    Join Date
    Sep 2006
    Posts
    450
    Tokens
    0

    Default [Tutorial] Rares Values System.

    Can't be bothered to sell it soo..

    Ok start by running the following queries.

    PHP Code:
    CREATE TABLE `rares` (
      `
    idsmallint(6NOT NULL auto_increment,
      `
    titlevarchar(30NOT NULL default '',
      `
    categorytinyint(6NOT NULL default '0',
      `
    imagevarchar(100NOT NULL default '',
      `
    datevarchar(20NOT NULL default '',
      `
    namevarchar(255) default '',
      
    UNIQUE KEY `id` (`id`)
    ENGINE=MyISAM AUTO_INCREMENT=36 DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ;


    CREATE TABLE `cats` (
      `
    idtinyint(4NOT NULL auto_increment,
      `
    namevarchar(30NOT NULL default '',
      
    UNIQUE KEY `id` (`id`)
    ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 
    Now make a file called 'db.php' and put the following in it:

    PHP Code:
    <?

       $connection 
    mysql_connect("localhost","USERNAME","PASSWORD"); //Connects to the database

       
    mysql_select_db(DATABASENAME) or die(mysql_error()); //Selects the database to read from.

    ?>
    Next up make 'add_rv.php'

    PHP Code:
    <style type="text/css">
    <!--
    .everything {
    background-color: #97CBFF;
    border: 1px dashed #000000;
    font-family: Verdana;
    font-size: 8pt;
    }
    -->
    </style>

    <?

    include("db.php");

    ?>
    <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#97CBFF" width="500" id="AutoNumber1">
      <tr>
        <td width="500">
    <FORM action="create_rv.php" method="post">
    <font face="Verdana" size="1"><b>Welcome RVR.</b><br>Welcome to the Rares Values Management page, you can use this page to add a Rares Value, remember this can be edited later on so you dont have to make a new rare everytime it changed in value...<br><br>
    <b>Name of Rare:</b><br>
    <input type="text" class="everything" size="20" name="rname"><br><br>
    <b>Current Value of Rare:</b>
    <br><input type="text" size="20" class="everything" name="title"><br><br>
    <b>URL of Rare Image:<br></b>
    <input type="text" class="everything" size="20" name="image"></textarea><br><br>
    <b>Which Category is the Rare In:<br></b>
    <select class="everything" name="category">
    <?php
    include ('db.php'); //Includes the connection file
    $query="SELECT name FROM cats"//Selects the categorys from the database
    $res mysql_query($query$connection) or die ('Error during the execution of the MySQL query : ' mysql_error()); //Connects to the database
    while ($row mysql_fetch_array($res)) //Echos out all the catergorys
    {
    echo 
    "<OPTION>$row[name]</OPTION><br>"//Shows the categorys in a dropdown menu
    //Ends the function
    ?>
    </select><br><br>
    <input type="submit" class="everything" value="Submit">
    </FORM><br>
    Ok now make 'create_rv.php'

    PHP Code:
    <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#97CBFF" width="500" id="AutoNumber1">
      <tr>
        <td width="500">
    <?php
    $image
    =$_REQUEST['image']; //Gets the image destination
    $title=$_REQUEST['title']; //Gets the value
    $category=$_REQUEST['category']; //Gets the category that you chose
    $date date('F jS, Y'); //Logs the date
    $name $_REQUEST['rname']; //Gets the name of the rare
    include ('db.php'); //Includes the configuration file
    $query "SELECT * FROM categories WHERE name = '$category'"//Selects the category you chose
    $res mysql_query($query$connection) or die ('Error during the execution of the MySQL query : ' mysql_error()); //Connects to the database
    $row mysql_fetch_array($res); //Variable for the row
    $cat $row['id']; //Variable for the ID
    $query "INSERT INTO rares VALUES ('', '$title', '$cat', '$image', '$date','$name')"//Inserts the value into the database
    $result mysql_query($query$connection) or die ('Error during the execution of the MySQL query : ' mysql_error()); //Writes to the database
    echo "<font face=\"Verdana\" size=\"1\"><b>Thankyou</b><br><br>The Rare Value has successfully been added."//Says thanks for submitting a value
    ?>
    </table></tr>
    Ok that will add a rare value, but how can we add it into a category when there is none???

    Make addcat.php

    PHP Code:
    <style type="text/css">
    <!--
    .
    everything {
    background-color#97CBFF;
    border1px dashed #000000;
    font-familyVerdana;
    font-size8pt;
    }
    -->
    </
    style>
    <
    table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#97CBFF" width="500" id="AutoNumber1">
      <
    tr>
        <
    td width="500">
    <
    font face="Verdana" size="1"><b>Add Category</b><br>
    Please enter a name for the Category and press done.<br><br>
    <
    FORM ACTION="addcat2.php" METHOD="POST">
    <
    b>Name of Category:</b><br><input type="text" class="everything" size="20" name="cagetory"><br><br>
    <
    input type="submit" class="everything" value="Submit">
    </
    FORM>
    </
    table></tr
    Can't really comment in that as theres no PHP

    Make addcat2.php now

    PHP Code:
    <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#97CBFF" width="500" id="AutoNumber1">
      <tr>
        <td width="500">
    <?php
    $cat
    =$_REQUEST['cagetory']; //Gets the category name
    include ('db.php'); //Includes the configuration file
    $query="INSERT INTO cats (id, name) VALUES ('', '$cat')"//Inserts the data into the database
    $result mysql_query($query$connection) or die ('Error during the execution of the MySQL query : ' mysql_error()); //Connects to database
    echo "<font face=\"Verdana\" size=\"1\"><b>Category Added</b><br><br>The category has been successfully added."//Added the cdtegory
    ?>
    </table>
    </tr>
    Ok now make values_1.php to show the categorys

    PHP Code:
    <?php
    include ('db.php'); //Includes the configuration fole
    $query="SELECT * FROM cats"//Selects all the categorys from the dtabase
    $res mysql_query($query$connection) or die ('Error during the execution of the MySQL query : ' mysql_error()); //Connects to DB
    while ($row mysql_fetch_array($res)) //Echos out all categorys
    {
    echo 
    "View <a href=\"values_2.php?id=$row[id]\">$row[name]</a><br>"//Format to show each link to each category in, if you get me!
    }
    ?>
    Ok now make values_2.php to show the rares from the category you choose in the values_1.php file

    PHP Code:
    <HTML>
    <HEAD>
    <TITLE>---</TITLE>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">
    </HEAD>
    <BODY onLoad="if ('Navigator' == navigator.appName) document.forms[0].reset();">
    <?php
    include ('db.php'); //Includes the config file
    $id=$_REQUEST['id']; //Gets the id of the cateogyr you chose
    $query="SELECT name FROM cats WHERE id = '$id'"//Selects the rares from the catgegory
    $res mysql_query($query$connection) or die ('Error during the execution of MySQL : ' mysql_error());
    $row mysql_fetch_array($res); //Gets the row(s)
    $cat $row['name']; //The category is the row name
    $query="SELECT * FROM rares WHERE category = '$id'"//Selects the rares from this category only
    $res mysql_query($query$connection) or die ('Error during the execution of the MySQL query : ' mysql_error()); //Conects to the DB
    while ($row mysql_fetch_array($res)) //Echos out all rares
    {
    echo 
    "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"80\" id=\"AutoNumber1\"><tr>
        <td width=\"80px\" border=\"1px\"><font face=\"Verdana\" size=\"1\"><p align=\"center\"><img src=\"
    $row[image]\" alt=\"Value Added on $row[date]\"><br>$row[title]</a>
      </tr></table>&nbsp;"
    //What each rare will display like
    }
    if (
    mysql_num_rows($res) == "0"//If theres no rares in this category
    {
    echo 
    "The staff on this site are lazy and havent added any rares yet ^_^"//Tells the user the breaking news
    }
    ?>
    </body>
    </html>
    Ok nearly done, now to make the file to edit the rares, this is proberly the biggest file yet, call it edit_rare.php

    PHP Code:
    <style type="text/css">
    <!--
    .form {
    background-color: #97CBFF;
    border: 1px dashed #000000;
    font-family: Verdana;
    font-size: 8pt;
    }
    -->
    </style>
    <table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#97CBFF" width="500" id="AutoNumber1">
      <tr>
        <td width="500">
    <?
    include("db.php"); //includes config file
    if($_GET[rares]) //If there is a ?rare=blabla in the URL
    {
    if (!
    $_POST[update]) //If you havent updated the rare yet
    {
    $rares mysql_query("SELECT * from rares where name = '$_GET[rares]'"); //Select the rare to edit from the database where the name is the same as the rare you chose to edit

    $rares mysql_fetch_array($rares); //Makes an array of the rares

    echo("<font face=\"verdana\" size=\"1\"><b>Edit A Rare</b><br /><br />
    <form method=\"POST\">
    Rare Name:<br />
     <input type=\"text\" class=\"form\" size=\"25\" maxlength=\"40\" name=\"name\" value=\"
    $rares[name]\"><br /><br />
    Rare Value:<br />
     <input type=\"text\" class=\"form\" size=\"25\" maxlength=\"40\" name=\"value\" value=\"
    $rares[title]\"><br /><br />
    Image:<br />
     <input type=\"text\" class=\"form\" size=\"25\" maxlength=\"40\" name=\"image\" value=\"
    $rares[image]\"><br /><br />
    <input type=\"submit\" class=\"form\" name=\"update\" value=\"Update Rare\"><br /><br />
    Name MUST be left the same or the rare will NOT update.

    "
    );//Echos out the form
    }
    else 
    //If they HAVE updated the rare
    {
    $value htmlspecialchars($_POST[title]); //Gets the actual value
    $name htmlspecialchars($_POST[name]); //Gets the name of the rare
    $image htmlspecialchars($_POST[image]); //Gets the image destrination

    echo ("<font face=\"verdana\" size=\"1\"><b>Rare Updated</b><br /><br />the rare was successfully updated."); //Say thanks for updating the rare
    $update mysql_query("Update rares set title = '$value', 
    name = '
    $name', image = '$image' where name = '$name'"); //update the database where the name is the rare you chose to edit

    }
    }
    else 
    //If they havent chose a rare to edit yet
    {
    echo(
    "<font face=\"verdana\" size=\"1\"><b>Choose a Rare to Edit</b><br>"); //Makes the header thing at the top
    $getrares mysql_query("Select * from rares order by name asc"); //Gets all the rares from the database
    while($rares mysql_fetch_array($getrares)) //Echos out each and every rare
    {
    echo(
    "<a href=\"?rares=$rares[name]\">$rares[name]</a><br />"); //Display format for each rare
    }
    //Ends functions
    ?>
    </table>
    And thats that ^_^

    Good luck, there is no errors in this and you cant complain i haven't comented enough as there is like a comment on each line ^_^ Enjoy!

    Copyright PixelResources.co.uk - Tutorials - 2006 - 2007 used on habboxforum with permission from owner (Me)
    Last edited by J1MI; 26-10-2006 at 10:47 PM.

  2. #2
    Join Date
    Aug 2005
    Posts
    1,080
    Tokens
    0

    Latest Awards:

    Default

    Sticky it , its quality and maybe habbox.com may want to use it?
    Back?

  3. #3
    Eternity Guest

    Default

    I don't like it, shoddy.

  4. #4
    Join Date
    Sep 2006
    Posts
    450
    Tokens
    0

    Default

    Doubt it, might come in useful for many people i had a pm asking for it for free so here it is ^_^
    Last edited by RyanS; 16-09-2006 at 12:10 PM.

  5. #5
    Join Date
    May 2006
    Location
    Huntingdon (Cambridgeshire UK)
    Posts
    3,395
    Tokens
    0

    Latest Awards:

    Default

    It needs a little touching up on some parts in the addcat section. But apat from that sticky wirthy

  6. #6
    Join Date
    Sep 2006
    Posts
    450
    Tokens
    0

    Default

    Anyone can edit it, i cant make it look great for everyones needs they cant edit it persoanlly.

  7. #7
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    2,492
    Tokens
    147

    Latest Awards:

    Default

    Nice tutorial

    Greets,
    Olivier Pauwels.

  8. #8
    Join Date
    Feb 2006
    Location
    Inside your PC
    Posts
    1,626
    Tokens
    0

    Latest Awards:

    Default

    Nice

    thanks for this +rep

    Mods you must sticky this

  9. #9
    Join Date
    Mar 2006
    Location
    Scotland
    Posts
    1,012
    Tokens
    175

    Latest Awards:

    Default

    Very nice of you Ryan. You have been in a helping mood today. I've not tried it but it looks quite good and due to what has been said I think it must be quite good.

    +Rep for you


    You don't like me
    Chances are I don't like you.

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

    Latest Awards:

    Default

    Nice but Habbox will not use it since they have their own.

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
  •