1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What was the first script you created using PHP?

Discussion in 'PHP' started by Gatorade, Jun 16, 2007.

  1. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #41
    This one was my first
    Called "random number"
    
    <?
    
    $Number=rand(1,100);
    
    
    print "$Number";
    
    ?>
    
    PHP:
    Second
    called "Random number Divide"
    
    <?
    
    $Number=rand(1,100);
    $Divide = $Number / 2;
    
    print "$Number
    <br>
    $Divide";
    
    ?>
    
    PHP:
    Third
    called "user divide by two"
    
    <?
    
    
    $Number=$_POST[entry];
    $entry=$Number / 2;
    $picked_number="The number you picked was<br><b> $Number</b><br>";
    $result="Dividing it by two is <br><b>$entry</b>";
    
    if(!isset($Number)) { $picked_number="<b>Input any number into the box below</b>"; $result="<b>Your number will be divided by 2 and shown here</b>"; }
    
    print "
    <center>
    <table>
    <tr>
    <td align=center valign=middle>
    
    $picked_number
    <br><br>
    <form method='post' action=test.php>
    
    
    <input type='text' name='entry' value='$Number' maxlength='10'><br><br>
    <input type='submit' name='submit' value='Divide'>
    </form>
    $result
    
    
    </td>
    </tr></table>";
    
    
    
    ?>
    
    PHP:
    and Forth
    called "color = number"
    <?
    $number=$_POST[numberentered];
    $black="bgcolor='black'";
    $white="bgcolor='white'";
    $yellow="bgcolor='yellow'";
    $blue="bgcolor='blue'";
    $red="bgcolor='red'";
    $orange="bgcolor='orange'";
    $grey="bgcolor='grey'";
    $purple="bgcolor='purple'";
    $green="bgcolor='green'";
    $text_before="<b>Pick a number between 1 and 9</b>";
    $text_after="<b>YAY, You picked the number<br>$number</b>";
    $bgcolor='';
    $text='';
    $wrong="<b>You picked $number<br> Theres no color for $number yet!</b>";
    if(!isset($number)) 
    { 
    $text="<b>Pick a Number</b>";
    
    }
    
    elseif($number==1)
    {
    $text_before=$text_after;
    $bgcolor=$black;
    }
    
    elseif($number==2)
    {
    $text_before=$text_after;
    $bgcolor=$red;
    }
    
    elseif($number==3)
    {
    $text_before=$text_after;
    $bgcolor=$yellow;
    }
    
    elseif($number==4)
    {
    $text_before=$text_after;
    $bgcolor=$white;
    }
    
    elseif($number==5)
    {
    $text_before=$text_after;
    $bgcolor=$blue;
    }
    
    elseif($number==6)
    {
    $text_before=$text_after;
    $bgcolor=$green;
    }
    
    elseif($number==7)
    {
    $text_before=$text_after;
    $bgcolor=$orange;
    }
    
    elseif($number==8)
    {
    $text_before=$text_after;
    $bgcolor=$grey;
    }
    
    elseif($number==9)
    {
    $text_before=$text_after;
    $bgcolor=$purple;
    }
    
    else{
    $text_before=$wrong;
    $text="<b>BOOOO!</b>";
    }
    
    Print"
    
    <center>
    
    <br>
    <TABLE BORDER=1>
    <TR>
      <TD $bgcolor width='50' height='50' value='value' name='name'>$text</TD>
     
    
    </TABLE>
    $text_before
    <form method='post' action=test.php>
    
    
    <input type='text' name='numberentered' value='$number' maxlength='1'><br>
    <input type='submit' name='submit' value='Click'>
    </form></center>";
    
    ?>
    PHP:

    Then i lost interest in php a bit when i got discouraged. :( I tried to make a calculator and it all went to hell. This was the code. :(
    SEMrush
    
    <style type="text/css">
    
    .size {width: 50px; height: 50px;}
    .cesize {width: 200px;}
    
    </style>
    <body bgcolor='grey'>
    <?
    
    $one=1;
    $two=2;
    $three=3;
    $four=4;
    $five=5;
    $six=6;
    $seven=7;
    $eight=8;
    $nine=9;
    $zero=0;
    $entry=$_POST[input];
    $clear="CLEAR";
    $add="+";
    $divide="/";
    $multiply="X";
    $subtract="-";
    $negative="+/-";
    $decimal=".";
    $enter="ENTER";
    print"
    <center><TABLE BORDER=1>
    <TABLE BORDER=1>
    <form method='post' action=test.php>
    <TR>
      <TD><input type='text' name='input' value='$entry' maxlength='10'>
    </TD>
    </TR>
    </TABLE>
    
    
    
    <TABLE BORDER=1>
    
    
    <TR>
      <TD align='right'><input type='submit' name='input' value='$one' class='size'></TD>
      <TD><input type='submit' name='input' value='$two' class='size'></TD>
      <TD><input type='submit' name='input' value='$three' class='size'></TD>
    <TD><input type='submit' name='input' value='$add' class='size'></TD>
    
    </TR>
    <TR>
      <TD align='right'><input type='submit' name='input' value='$four' class='size'></TD>
      <TD><input type='submit' name='input' value='$five' class='size'></TD>
      <TD><input type='submit' name='input' value='$six' class='size'></TD>
    <TD align='center'><input type='submit' name='input' value='$subtract' class='size'></TD>
    </TR>
    <TR>
      <TD align='right'><input type='submit' name='input' value='$seven' class='size'></TD>
      <TD><input type='submit' name='input' value='$eight' class='size'></TD>
      <TD><input type='submit' name='input' value='$nine' class='size'></TD>
    <TD><input type='submit' name='input' value='$multiply' class='size'></TD>
    </TR>
    <TR>
      <TD><input type='submit' name='input' value='$negative' class='size'></TD>
      <TD><input type='submit' name='input' value='$zero'  class='size'></TD>
    <TD align='center'><input type='submit' name='input' value='$decimal' class='size'></TD>
      <TD align='center'><input type='submit' name='input' value='$divide' class='size'></TD>
    </TR>
    <TABLE BORDER=1>
    
    
      
      <TR>
     
    <TD><input type='submit' name='input' value='$enter' class='cesize'></TD>
    </tr>
    <tr>
     <TD><input type='submit' name='input' value='$clear' class='cesize'></TD>
    
      
    </TR>
    </TABLE>
    </table>
    
    
    
    </TABLE></center>";?>
    
    Code (markup):
     
    Dirty-Rockstar, Jun 23, 2007 IP
    SEMrush