Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, April 15, 2013

Codecademy Sample Solution: Your First 'if'


<html>
  <head>
    <title>Our Shop</title>
  </head>
  <body>
    <p>
      <?php
        $items = 7;    // Set this to a number greater than 5!
        if ($items > 5){
          echo "You get a 10% discount!";
        }
      ?>
    </p>
  </body>
</html>

Codecademy Sample Solution: Making Comparisons


<html>
  <head>
    <title>Comparing Numbers</title>
  </head>
  <body>
    <p>
      <?php
        $teabags = 3;
        if($teabags < 7)
            echo "true";
      ?>
    </p>
  </body>
</html>

Saturday, March 23, 2013

Scrolling Text Using Javascript


This is the scrolling text.

Code for the scrolling effect is written below:

<style type="text/css">
#scroll{
         position : absolute;
      white-space : nowrap;
              top : 0px;
             left : 200px;
       }
#oScroll{
    margin : 1px;
   padding : 0px;
         position : relative;
            width : 450px; /* width of the scroll box */
           height : 20px;
         overflow : hidden;
        }
      </style>
      <script type="text/javascript">
     function scroll(oid,iid){
          this.oCont=document.getElementById(oid)
          this.ele=document.getElementById(iid)
          this.width=this.ele.clientWidth;
          this.n=this.oCont.clientWidth;
          this.move=function(){
             this.ele.style.left=this.n+"px"
             this.n--
             if(this.n<(-this.width)){this.n=this.oCont.clientWidth}
                              }
                             }
     var vScroll
     function setup(){
         vScroll=new scroll("oScroll","scroll");
         setInterval("vScroll.move()",50) //controls the speed of scrolling, higher means slower
                     }
  onload=function(){setup()}
      </script>
<br />
<div id="oScroll">
<div id="scroll">
This is the <a href="http://questionsans.blogspot.com/2013/03/scrolling-text-using-javascript.html">scrolling text</a></div>
</div>

Friday, March 8, 2013

Codecademy Sample Solution: Echo It!


<!DOCTYPE html>
<html>
    <head>
        <link type='text/css' rel='stylesheet' href='style.css'/>
<title>PHP FTW!</title>
</head>
<body>
        <!-- Write your PHP code below!-->
        <p>
        <?php
            $myName = "Batman";
            echo "My name is ".$myName.". <br>";
            $myAge = 24;
            echo "I'm ".$myAge." years old."
        ?>  
        </p>  
</body>
</html>

Codecademy Sample Solution: Let The Machine Do The Math


<!DOCTYPE html>
<html>
    <head>
        <link type='text/css' rel='stylesheet' href='style.css'/>
<title>PHP FTW!</title>
</head>
<body>
        <!-- Write your PHP code below!-->
        <p>
        <?php
            $myName = "Batman";
            echo "My name is ".$myName.". <br>";
            $myAge = 24;
            echo "I'm ".$myAge." years old."
        ?>  
        </p>  
</body>
</html>

Codecademy Sample Solution: Creating a Variable


<!DOCTYPE html>
<html>
    <head>
        <link type='text/css' rel='stylesheet' href='style.css'/>
<title>PHP FTW!</title>
</head>
<body>
        <!-- Write your PHP code below!-->
        <p>
        <?php
            $myName = "Batman";
            echo $myName;
        ?>  
        </p>  
</body>
</html>

Thursday, March 7, 2013

Codecademy Sample Solution: Comments


<!DOCTYPE html>
<html>
<head>
<title>Oh No!</title>
</head>
<body>
        <p><?php
            echo "Oh, the humanity!";
            //whatever I like!
          ?></p>
    </body>
</html>

This is an example of scrolling text using Javascript.

Popular Posts