Tuesday 16 April 2013

PHP MySQL Tutorial: Simple MySQL Config Class

config.php
<?php
 class Config {
  // Config variables
  public $_host = "host"; // eg. localhost
  public $_username = "username";
  public $_password = "password";
  public $_dbname = "dbname"; // Database name
  
  // Constructor
  public function __construct(){
  }
 }
?>
index.php
<?php
 // Include config class file
 include("config.php");
 
 // Create config class
 $config = new Config();
 
 // Create connection
 $con = mysqli_connect($config->_host, $config->_username, $config->_password, $config->_dbname);
 
 // Check connection
 if (mysqli_connect_errno($con))
  die("Failed to connect to MySQL: " . mysqli_connect_error());
 
 echo "MySQL successfully connected!"
?>

Saturday 13 April 2013

Manga Character Design 1 By DinoCaspero

PHP Basic Calendar Tutorial By UnknownGhost03 Fix!

<html>

 <head>
  
  <title>PHP Basic Calendar</title>
  
  <script>
   function goLastMonth(month, year){
    if(month == 1) {
     --year;
     month = 13;
    }
    --month
    var monthstring = ""+month+"";
    var monthlength = monthstring.length;
    if(monthlength <=1){
     monthstring = "0" + monthstring;
    }
    document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year;
   }
   function goNextMonth(month, year){
    if(month == 12) {
     ++year;
     month = 0;
    }
    ++month
    var monthstring = ""+month+"";
    var monthlength = monthstring.length;
    if(monthlength <=1){
     monthstring = "0" + monthstring;
    }
    document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+monthstring+"&year="+year;
   }
  </script>
  
 </head>
 
 <body>
 
  <?php
   //get current date or specific month and year
   if (isset($_GET['day'])){
    $day = $_GET['day'];
   } else {
    $day = date("d");
   }
   if(isset($_GET['month'])){
    $month = $_GET['month'];
   } else {
    $month = date("m");
   }
   if(isset($_GET['year'])){
    $year = $_GET['year'];
   }else{
    $year = date("Y");
   }
   
   //get date data for display such as month name
   $currentTimeStamp = strtotime( "01-$month-$year");
   $monthName = date("F", $currentTimeStamp);
  ?>
  
  <table border="1px" cellpadding="0px" cellspacing="0px">
   <tr>
    <td align="center">
     <input style='width:50px;' type='button' value='<'name='previousbutton' onclick ="goLastMonth(<?php echo $month.','.$year?>)">
    </td>
    <td align="center" colspan="5"><?php echo $monthName." ".$year; ?></td>
    <td align="center">
     <input style='width:50px;' type='button' value='>'name='nextbutton' onclick ="goNextMonth(<?php echo $month.','.$year?>)">
    </td>
   </tr>
   <tr>
    <td align="center" width='100px'>Sunday</td>
    <td align="center" width='100px'>Monday</td>
    <td align="center" width='100px'>Tuesday</td>
    <td align="center" width='100px'>Wednesday</td>
    <td align="center" width='100px'>Thursday</td>
    <td align="center" width='100px'>Friday</td>
    <td align="center" width='100px'>Saturday</td>
   </tr>
   <tr>
    <?php
     //get the number of days in the current month and year
     $numDays = date("t", $currentTimeStamp);
     
     //keep track of the number of cell created
     $counter = 0;
     
     for($i = 1; $i < $numDays+1; $i++, $counter++){
      $timeStamp = strtotime("$year-$month-$i");
      
      //create empty cell until first day of the month
      if($i == 1) {
       $firstDay = date("w", $timeStamp);
       for($j = 0; $j < $firstDay; $j++, $counter++) {
        echo "<td>&nbsp;</td>";
       }
      }
      
      //create new row
      if($counter % 7 == 0) {
       echo"</tr><tr>";
      }
      
      //print day number
      echo "<td>$i</td>";
     }
     
     //fill up the leftover cells of the table
     while($counter % 7 != 0) {
      echo "<td>&nbsp;</td>";
      $counter++;
     }
    ?>
   </tr>
  </table>

 </body>
 
</html>

Friday 5 April 2013

HTML5 Tutorial: Basic Structure

<!DOCTYPE html>
<html lang="en">

 <head>
 
  <meta charset="utf-8" />
  <title>Website Title Here</title>
  
 </head>
 
 <body>
  
 </body>
 
</html>


Tag lists link: