Professional Web Applications Themes

A real challenge for real PHP programmers - PHP Development

<?php /* A challenge to every PHP programmer.The one who's gonna solve this problem would be deemed as PSP(PHP Supreme Programmer).The problem is this : You have to write a script that displays a list of categories and subcategorieslike this one: <select name="category"> <option value="1">Main</option> <option value="2">Main > Computers</option> <option value="4">Main > Computers > Hardware </option> <option value="8">Main > Computers > Hardware > PC</option> <option value="7">Main > Computers > Hardware > Mac</option> <option value="9">Main > Computers > Hardware > Atari</option> <option value="11">Main > Computers > Hardware > PC > History of Pc</option> <option value="">etc...</option> </select> The categories and subcategories details ...

  1. #1

    Default A real challenge for real PHP programmers

    <?php
    /*
    A challenge to every PHP programmer.The one who's gonna solve this
    problem would be deemed as

    PSP(PHP Supreme Programmer).The problem is this : You have to write a
    script that displays a list of

    categories and subcategorieslike this one:

    <select name="category">
    <option value="1">Main</option>
    <option value="2">Main > Computers</option>
    <option value="4">Main > Computers > Hardware </option>
    <option value="8">Main > Computers > Hardware > PC</option>
    <option value="7">Main > Computers > Hardware > Mac</option>
    <option value="9">Main > Computers > Hardware > Atari</option>
    <option value="11">Main > Computers > Hardware > PC > History of
    Pc</option>
    <option value="">etc...</option>
    </select>


    The categories and subcategories details are stored in these two
    tables in a MySQL database.
    -categories : the categories names and ids.
    -cat_relations : the relations between categories.It shows which
    subcategory belongs to which category.
    The belongings between categories can go very deep and the number of
    categories is unlimited. This script will create the two tables and
    fill them with sample data. All you need to do is to change the four
    variables below. You can send the script back to this email :
    com.
    */

    //Here starts the script. Please change the values of these variables
    to fit your settings
    $user = "prospective_PSP";
    $database = "db";
    $server = "localhost" ;
    $pwd = "" ;
    //Connection to the database that you created
    mysql_connect($server,$user,$pwd) ;
    mysql_select_db($database);
    //Creation of the two tables : categories and cat_relations
    $categories = " CREATE TABLE `categories` (`id` INT not null
    AUTO_INCREMENT, `name` VARCHAR(100) not null , PRIMARY KEY (`id`),
    INDEX (`id`), UNIQUE (`id`)) comment = 'The categories details' ";
    mysql_query($categories) ;
    $cat_relations = "CREATE TABLE `cat_relations` (`id` INT not null
    AUTO_INCREMENT, `daughter_id` INT not null, `mother_id` INT not null ,
    PRIMARY KEY (`id`), INDEX (`id`), UNIQUE (`id`)) comment = 'Which
    category is the daughter of which category'";
    mysql_query($cat_relations) ;

    //Filling the two tables with sample data
    $cats = array('Main','Computers','Countries','Hardware','S oftware','Programming
    languages','Mac','PC','Atari','Winamp','History of the
    PC','IBM','Components','High
    level','USA','NYC','LA','Manhattan','India','Winzi p');
    for ($i=0;$i<count($cats);$i++){
    $sql = mysql_query("insert into categories (name)
    values('".$cats[$i]."')");
    }
    mysql_query("insert into cat_relations (daughter_id,mother_id) values
    (2,1),(3,1),(4,2),(5,2),(6,2),(7,4),(8,4),(9,4),(1 1,8),(12,8),(13,8),(10,5),(20,5),(14,6),(15,3),(16

    ,15),(17,15),(18,16),(19,3)");
    //Now you can have a look on them through phpMyAdmin
    ?>
    Brian Guest

  2. #2

    Default Re: A real challenge for real PHP programmers

    On 12 Dec 2003 20:38:23 -0800, com (Brian Murphy) wrote:
     

    Are you trying to get custom made scripts for free?

    If you are having trouble with a piece of code and need some help, just
    ask. That's one thing, but I suspect you are just being cheap. I'm sure
    there are a lot of good PHP coders here that would be more than willing to
    write your code for you, provided you reciprocate with cash.

    Just my humble opinion.

    T

    Tom Guest

  3. #3

    Default Re: A real challenge for real PHP programmers

    Tom Lynn <com> writes:
     
    >
    > Are you trying to get custom made scripts for free?
    >
    > If you are having trouble with a piece of code and need some help, just
    > ask. That's one thing, but I suspect you are just being cheap. I'm sure
    > there are a lot of good PHP coders here that would be more than willing to
    > write your code for you, provided you reciprocate with cash.
    >
    > Just my humble opinion.[/ref]

    Not to mention the low standard for the "PHP Supreme Programmer"
    appellation. Sounds more like a kind of pizza.

    --
    Michael Fuhr
    http://www.fuhr.org/~mfuhr/
    Michael Guest

  4. #4

    Default Re: A real challenge for real PHP programmers

    Tom Lynn wrote: 

    Sounds more like some cheesy kid trying to get his homework done for free.
    --
    Bob
    Robert Guest

Similar Threads

  1. Question / challenge for any REAL flash guru
    By ninjateapartyover in forum Macromedia Flash Flashcom
    Replies: 0
    Last Post: April 22nd, 08:38 AM
  2. Need Help! - A real query challenge
    By Leonard B in forum Macromedia ColdFusion
    Replies: 0
    Last Post: April 21st, 07:25 AM
  3. For real?!!
    By Hexebah@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 15
    Last Post: March 3rd, 12:02 AM
  4. Replies: 0
    Last Post: July 7th, 09:08 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139