i'm PHP Programmer and i'm Here to Help PHP developers with php coding




All time Best CSS3 Code Generators

Here are some Great Collection for CSS3 Code Generators Hope you will get maximum Help from this Post 




Have I missed your favorite CSS3 code generator?  if so you can post them in comments thanks


Read more...

Beginners Guide for Php Development

Nice Book I found For beginners

Beginners Guide for Php Development with MVC Architecture

Beginner's Guide to PHP Development with MVC Architecture Beginners Guide for Php Development with MVC Architecture


Read more...

Simple Usage for Mysql With Object Oriented Style......

Found This Simple Usage for Mysql With Object Oriented Style......From Facebook

<?php

/**
* mysqllib.php
* A Simple Usage of Mysql with
* Object Oriented Style
* Written Just For Manage The
* Functions Easly And Make the Funny
* The Connection :)
* */


/******************************
* Main Structure Of Library.. *
*******************************/


class MysqlLib
{
/**
* $Link : For Connection to Server
* with mysql_connect() function
* @access Public
* */

Public $Link;

/**
* $Dblink : Connection to Database
* with mysql_select_db() function
* @access Public
* */

Public $DbLink;

/**
* $SqlLink : For mysql_query() unction
* @access Public
* */

Public $SqlLink;

/**
* $NumRow: Getting Num Rows of Last Result
* or Last Query
* @access Public
* */

Public $NumRow;

/**
* $Error : for mysql_error()
* @access Public
* */

Public $Error;

/**
* $ErrNo : get the error code of last query
* @access Public
* */

Public $ErrNo;

/**
* $Assocative : for get mysql_fetch_assoc() function
* @access Public
* */

Public $Assocative;

/**
* Constructionof Class
* $host : mysql server name
* $user : mysql access username
* $pass : mysql access password
* $db : your database
* */

function __construct($host,$user,$pass,$db)
{
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->dbnm = $db;
}

/**
* Gets the Host name By the __construct function
* @access Public
* @return Bool
* */

Public Function getHost()
{
return $this->host;
}

/**
* Gets the username By the __construct function
* @access Public
* @return String
* */

Public Function getUser()
{
return $this->user;
}

/**
* Gets the password By the __construct function
* @access Public
* @return String
* */

Public Function getPass()
{
return $this->pass;
}

/**
* Gets the Database By the __construct function
* @access Public
* @return String
* */

Public Function getDb()
{
return $this->dbnm;
}

/**
* Make connection For Server And Database
* @access Public
* @return Bool
* */

Public Function init()
{
$this->Link = mysql_connect($this->getHost(),$this->getUser(),$this->getPass()) or die(mysql_error());
$this->DbLink = mysql_select_db($this->getDb(),$this->Link) or die(mysql_error());
}

/**
* Sends the Sql Query to Server
* @access Public
* @return Bool
* */

Public Function initSql($sql)
{
$this->SqlLink = mysql_query($sql) or die(mysql_error());

return $this->SqlLink;

}

/**
* Gets Affected Num Rows By the Last Query
* @access Public
* @return Int
* */

Public Function getNumRow()
{
$this->NumRow = mysql_num_rows($this->SqlLink) or die(mysql_error());

return $this->NumRow;

}

/**
* Gets All Given Data to assocative Array
* @access Public
* @return String
* */

Public Function FetchAssoc()
{
$this->Assocative = mysql_fetch_assoc($this->SqlLink) or die(mysql_error());

return $this->Assocative;
}

/**
* Gets The Last error
* @access Public
* @return String
* */

Public Function getError()
{
$this->Error = mysql_error();

return $this->Error;
}

/**
* Gets the Error Code of Last operation
* @access Public
* @return Int
* */

Public Function getErrorNo()
{
$this->ErrNo = mysql_errno();

return $this->ErrNo;
}

}

?>




Read more...

Control structure condition statement(if,else if,else, switch case)example in PHP programming language


<html> <head> <title>Untitled Document</title> </head> <body>
<form method="get" action="<? $_SERVER["PHP_SELF"] ?>"/>
Your qualification: <input name="saje" type="radio" value="DEGREE" checked="checked" /> degree
<input name="saje" type="radio" value="MASTER" /> master Your salary
<select name="salary"> <option value="" selected="selected">please select</option> <option value="1">BELOW RM1000 </option> <option value="2">RM1000 TO RM2000</option> <option value="3">RM2000 TO RM3000</option> <option value="4">ABOVE RM3000</option> </select>
<input type="submit" value="PROCEEDAA">
</form>

<?
echo " ";
echo "KELULUSAN HANG:".$_REQUEST['saje'];
echo " ";
$salary = $_REQUEST['salary'];


if($salary=="1") { echo "gaji hang below RM1000"; }
else if($salary=="2") { echo "gaji hang antara RM1000 ke RM2000"; }
else if($salary=="3") { echo "gaji hang antara RM2000 ke RM3000"; }
else if($salary=="4") { echo "gaji hang atas RM4000"; }
else { echo "Hang tak pilih gaji";} echo " ";

switch($salary) {

case "1":
echo "gaji hang below RM1000";
break;

case "2":
echo "gaji hang antara RM1000 ke RM2000";
break;

case "3":
echo "gaji hang antara RM2000 ke RM3000";
break;

case "4":
echo "gaji hang atas RM4000";
break;

default: echo "Hang tak pilih gaji";
} ?>
</body> </html>


Read more...

The following XHTML rules differentiate it from HTML:

i found this in part of the book of php mysql & javascript
The following XHTML rules differentiate it from HTML:
• All tags must be closed by another tag. In cases in which there is no matching
closing tag, the tag must close itself using a space followed by the symbols / and
>. So, for example, a tag such as <input type='submit'> needs to be changed into
<input type='submit' />. In addition, all opening <p> tags now require a closing
</p> tag, too. And no, you can’t replace them with <p />.
• All tags must be correctly nested. Therefore the string <b>My first name is
<i>Robin</b></i> is not allowed, because the opening <b> has been closed before
the <i>. The corrected version is <b>My first name is <i>Robin</i></b>.



• All tag attributes must be enclosed in quotation marks. Instead of using tags
such as <form method=post action=post.php> you should instead use
<form method='post' action='post.php'>. You can also use double quotes:
<form method="post" action="post.php">.
• The ampersand (&) character cannot be used on its own. For example, the string
“Batman & Robin” must be replaced with “Batman &amp; Robin”. This means
that URLs require modification, too. So the HTML syntax <a href="index.php?
page=12&item=15"> should be replaced with <a href="index.php?
page=12&amp;item=15">.
• XHTML tags are case-sensitive and must be all in lowercase. Therefore HTML
such as <BODY><DIV ID="heading"> must be changed to the following syntax:
<body><div id="heading">.
• Attributes cannot be minimized any more, so tags such as <option name="bill"
selected> now must be replaced with an assigned value: <option name="bill"
selected="selected">. All other attributes such as checked and disabled also need
to be changed to checked="checked", disabled="disabled", and so on.
• XHTML documents must start with a new XML declaration on the very first line,
like this: <?xml version="1.0" encoding="UTF-8"?>.
• The DOCTYPE declaration has been changed.
• The <html> tag now requires an xmlns attribute.


Read more...

Basic DB Search Script

PHP Tutorial With MYSQL Coding
<?php
/**
 * @author Bradley Weston <admin@webod.co.uk>
 */


if(version_compare(PHP_VERSION, 5, '<'))
    die("Please upgrade your PHP.");
if(!class_exists('mysqli'))
    die("Please install Mysqli extention.");


class DB_Search {

    protected $DB = NULL;
    protected $Keywords = NULL;
    protected $searchTable = NULL;
    protected $searchColumns = NULL;
    protected $lastSearchResult = NULL;

    function __construct (){
        $this->Keywords = array();
        $this->searchColumns = array();
    }

    function setSearchTable ($Tablename){
        $this->searchTable = $Tablename;
    }

    function addSearchColumn ($Columnname){
        $this->searchColumns[] = $Columnname;
    }

    function DB_Connect ($Hostname, $Username, $Password, $Name, $Port = 3306){
        $this->DB = new mysqli(
            $Hostname,
            $Username,
            $Password,
            $Name,
            $Port
        );
    }




    function DB_Connect_Resource (mysqli &$Connection){
        $this->DB = $Connection;
    }

    function addKeyword ($Keyword){
        $this->Keywords[] = $Keyword;
    }

    function parseString ($String){
        array_map(array($this, 'addKeyword'), explode(' ', $String));
    }

    protected function query (){
        //You may want to make this query more percific to get exact results first
        //this is just a basic search for keywords
        $Q = '';
        foreach($this->searchColumns as $Column){
            foreach($this->Keywords as $Keyword){
                $Q .= sprintf("`%s` = '%s' ", $Column, $Keyword);
            }
        }
        $this->lastSearchResult = $this->DB->query(sprintf(
            "SELECT * FROM `%s` WHERE %s",
            $this->searchTable,
            $Q
        ));
    }

    function getResult (){
        if(!is_a($this->lastSearchResult, 'mysqli_result')) $this->query();
        $Result = $this->lastSearchResult->fetch_assoc();
        if($Result == NULL) return false;
        return $Result;
    }

}


//USAGE


$MyGlobalDBConnection = new mysqli('localhost', 'root', 'abcd1234', 'testdb');


$Search = new DB_Search;
$Search->DB_Connect_Resource($MyGlobalDBConnection);
$Search->setSearchTable('mytesttable');
$Search->addSearchColumn('keywords');
$Search->addSearchColumn('description');
$Search->addSearchColumn('product_name');


$Search->parseString('my test string');


while(false !== ($Result = $Search->getResult())){
    print_r($Result);
}







Read more...

CHAT BOX Ajax-PHP without Database

PHP Help 
CHAT BOX Ajax-PHP without Database

FILE 1 : index.php
<?php
session_start();

function createForm(){
?>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <table align="center">
          <tr><td colspan="2">Please eneter a nickname to login!</td></tr>
          <tr><td>Your name: </td>
          <td><input class="text" type="text" name="name" /></td></tr>
          <tr><td colspan="2" align="center">
             <input class="text" type="submit" name="submitBtn" value="Login" />
          </td></tr>
        </table>
      </form>
<?php
}



if (isset($_GET['u'])){
   unset($_SESSION['nickname']);
}

// Process login info
if (isset($_POST['submitBtn'])){
      $name    = isset($_POST['name']) ? $_POST['name'] : "Unnamed";
      $_SESSION['nickname'] = $name;
}

$nickname = isset($_SESSION['nickname']) ? $_SESSION['nickname'] : "Hidden";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Micro Chat AJAX-PHP</title>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
    <!--
      var httpObject = null;
      var link = "";
      var timerID = 0;
      var nickName = "<?php echo $nickname; ?>";

      // Get the HTTP Object
      function getHTTPObject(){
         if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
         else if (window.XMLHttpRequest) return new XMLHttpRequest();
         else {
            alert("Your browser does not support AJAX.");
            return null;
         }
      }

      // Change the value of the outputText field
      function setOutput(){
         if(httpObject.readyState == 4){
            var response = httpObject.responseText;
            var objDiv = document.getElementById("result");
            objDiv.innerHTML += response;
            objDiv.scrollTop = objDiv.scrollHeight;
            var inpObj = document.getElementById("msg");
            inpObj.value = "";
            inpObj.focus();
         }
      }

      // Change the value of the outputText field
      function setAll(){
         if(httpObject.readyState == 4){
            var response = httpObject.responseText;
            var objDiv = document.getElementById("result");
            objDiv.innerHTML = response;
            objDiv.scrollTop = objDiv.scrollHeight;
         }
      }

      // Implement business logic 
      function doWork(){ 
         httpObject = getHTTPObject();
         if (httpObject != null) {
            link = "message.php?nick="+nickName+"&msg="+document.getElementById('msg').value;
            httpObject.open("GET", link , true);
            httpObject.onreadystatechange = setOutput;
            httpObject.send(null);
         }
      }

      // Implement business logic 
      function doReload(){ 
         httpObject = getHTTPObject();
         var randomnumber=Math.floor(Math.random()*10000);
         if (httpObject != null) {
            link = "message.php?all=1&rnd="+randomnumber;
            httpObject.open("GET", link , true);
            httpObject.onreadystatechange = setAll;
            httpObject.send(null);
         }
      }

      function UpdateTimer() {
         doReload();
         timerID = setTimeout("UpdateTimer()", 5000);
      }


      function keypressed(e){
         if(e.keyCode=='13'){
            doWork();
         }
      }
    //-->
    </script>
</head>
<body onload="UpdateTimer();">
    <div id="main">
      <div id="caption">Micro Chat</div>
      <div id="icon">&nbsp;</div>
<?php

if (!isset($_SESSION['nickname']) ){
    createForm();
} else  {
      $name    = isset($_POST['name']) ? $_POST['name'] : "Unnamed";
      $_SESSION['nickname'] = $name;
    ?>

     <div id="result">
     <?php
        $data = file("msg.html");
        foreach ($data as $line) {
                echo $line;
        }
     ?>
      </div>
      <div id="sender" onkeyup="keypressed(event);">
         Your message: <input type="text" name="msg" size="30" id="msg" />
         <button onclick="doWork();">Send</button>
      </div>
<?php         
    }

?>
    </div>
</body>  FILE 2 : message.php
 <?php
                if (isset($_GET['msg'])){
                                if (file_exists('msg.html')) {
                                   $f = fopen('msg.html',"a+");
                                } else {
                                   $f = fopen('msg.html',"w+");
                                }
      $nick = isset($_GET['nick']) ? $_GET['nick'] : "Hidden";
      $msg  = isset($_GET['msg']) ? htmlspecialchars($_GET['msg']) : ".";
      $line = "<p><span class=\"name\">$nick: </span><span class=\"txt\">$msg</span></p>";
                                fwrite($f,$line."\r\n");
                                fclose($f);

                                echo $line;

                } else if (isset($_GET['all'])) {
                   $flag = file('msg.html');
                   $content = "";
                   foreach ($flag as $value) {
                                $content .= $value;
                   }
                   echo $content;

                }
?>FILE 3: msg.htmlnotes ! this is file empty!


Read more...