I'm a super-newbie when it comes to coding PHP. I started three days ago, yet I feel that I'm making progress. (and I'm new here, too, so if I do anything wrong, please let me know.. _)

However, I am unsure that I should be using PHP for the project on which I am working. So far everything seems to be working, but I've run into some "minor" problems when working on two different matters. First one:

I am trying to make a 'counter'.. only, I want it to reverse. I have a code that gives me a random number, and I'm trying to make a code that enables me to subtract several numbers from the a number, without resetting the original number every time. Uh... does that make sense?

Example:

100 - 20 = 80
80 - 12 = 68
etc.

Is it possible to do with PHP, or am I using the wrong language? god, I'm such a noob

Second.. I'm trying to make a kind-of 'paper-doll' script, that allows me to "equip " and "unequip" a shirt/some hair/whatever to a stickman. My main problem is.. I ahve no clue what -kind- of code should be used. I think it can be done in PHP, but so far I've seen nothing that I found remotely helpful. Perhaps if I get some kind of clue as to what kind I need, it'll help me.. o.o;

Uh.. if it's of any help, I'm using Macromedia Dreamweaver to code in. I use the w3schools.com tutorial on PHP, and I'm currently learning about loops. Is my aim hopeless? Am I too unexperienced to do anything remotely like what I want? Any pointers/guidelines/anything is helpful.. XD

By the way, if my english seems bad, it's because I'm european. Please bear with me.

    If you are looking to write a counter that counts down dynamically without refreshing the page, then PHP by itself is not suitable for the job. Likewise, if you have a concept of a game where users drag and drop items to clothe a doll, PHP by itself is also not suitable.

    On the other hand, writing PHP code that generates a pseudo-random number and uses it to decrease a counter is rather simple. Equipping a doll may be more difficult, but may still be possible.

    You may find that the PHP Manual is a very useful resource. The online book Practical PHP Programming is also a good read.

      Ah, thanks! _

      The pseudo-random decreasing counter is exactly what I'm looking for.
      As for the paper doll, I was thinking of having a link (image, whatever) for the "item", and upon clicking, the "doll" is... overwritten? What I mean is, the item is applied to the doll. I understand a drag-n-drop system would probably require something more like flash, but clicking a link like I described should be possible?

      I will take a look at the links you gave me. Thank you very much! _

        this isnt great coding, but its just to give you an idea how to make something IF you want to use PHP (javascript would be better)

        <?php
        
        $hat = $_GET['hat'] or $hat = "off";
        $shirt = $_GET['shirt'] or $shirt = "off";
        $pants = $_GET['pants'] or $pants = "off";
        
        echo "<p>Dress the doll</p>";
        
        if ($hat == "on") {
        	echo "<div align=\"center\"><a align=right href=\"test.php?hat=off&shirt=$shirt&pants=$pants\">Put the hat on!</a></div><br />";
        }
        else {
        	echo "<a href=\"test.php?hat=on&shirt=$shirt&pants=$pants\">Put the hat off!</a><br />";
        }
        
        if ($shirt == "on") {
        	echo "<div align=\"center\"><a href=\"test.php?hat=$hat&shirt=off&pants=$pants\">Put the shirt on!</a></span></div><br />";
        }
        else {
        	echo "<a href=\"test.php?hat=$hat&shirt=on&pants=$pants\">Put the shirt off!</a><br />";
        }
        
        if ($pants == "on") {
        	echo "<div align=\"center\"><a href=\"test.php?hat=$hat&shirt=$shirt&pants=off\">Put the pants on!</a></span></div><br />";
        }
        else {
        	echo "<a href=\"test.php?hat=$hat&shirt=$shirt&pants=on\">Put the pants off!</a><br />";
        }
        
        
        ?>
        

        name it test.php

        $hat = $_GET['hat'] or $hat = "off"; // this reads the data you send with the links
        
        test.php?hat=$hat&shirt=$shirt&pants=off  // this creates a link where pants is off  :p but the other 2 $hat and $shirt are dependend on the information you supplied earlier, with the $_GET variables.
        
        if ($pants == "on") // this looks what the string $pants is, and then does the code under it if its TRUE, or does the code under ELSE if its not true.
        

          Wow, thank you, Sangre!

          It seems to make sense, all I wonder is how I should apply one picture on top of another. But would you reckon that I should use javascript instead? It seems to be easier that way..

          Again, thank you so much! _

            Roger: Thank you. The thing is, though, that I am trying to create a system similar to that of the Avatars on these sites:

            www.gaiaonline.com
            www.zantarni.com

            On both sites, you can click on a link (or a picture, actually) and have the "avatar" dress up in whatever clothes you choose. I know that the latter site uses a php script for it.. and.. I'm trying to recreate a similar system.

            I thank you all for your help. If anyone has any more ideas, please let me know. Thank you! _

              Well the demo on your first link is using javascript to make the changes - probably using Sam Stephenson's prototype library that the scriptaculous stuff extends (most people are these days). The php comes in on the server-side to respond to the js request. Look at the status bar when you mouse over the change buttons on the demo and you'll see what I mean.

              The process is commonly known as AJAX so google around to find some tutorials on it. AJAX does not have to rely on php, could be any server scripting language like PERL or ASP. Thing is, if you want drag n drop then that link I gave is the best I know of, just as prototype is about the best ajax library.

                and if you really want to use PHP, do some tutorials about GD.

                WIth GD you can create images on the fly, like thumbnails and such.
                But you can also combine images into one, sending the image to the browser, and then delete it again. Then all thinkable combination are possible.

                but yeah everytime you select a new item for on your avatar, the page has to reload, which sux

                  Write a Reply...