Saturday, May 31, 2014

How To Find & Replace String using Mysql Query

if you  find a string in a certain field and replace it with another string in database table. Please use below code.








syntax:
update [table_name] set [field_name] = replace([field_name],’[string_to_find]‘,’[string_to_replace]‘);
or
 UPDATE `table_name`
 SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

For Exp:
update user set name = replace(name,’Gupta’,'Mishra’);

Friday, May 30, 2014

Display Page Execution Time Using Php

Use this Small code to check the execution time of your script.

<?php
// Write this line at the top of script
$start = (float) array_sum(explode(‘ ‘,microtime()));

/*
your code here
*/

// Write these lines at the bottom of script
$end = (float) array_sum(explode(‘ ‘,microtime()));
echo sprintf(“%.4f”, ($end-$start));
?>



If you want to increase the execution time limit then use these:

1. set_time_limit(int $seconds)

(See it – will not work in Safe Mode)

2. ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes

(See it – ini_set will not work in Safe Mode)

3. Via .htaccess

php_value max_execution_time 90

4. Also set php.ini - This maximum execution time limit is set inside the php.ini file like this.
max_execution_time = 30; Maximum execution time of each script, in seconds



For Example


<!--  this  code at the top of the page -->
<?php
   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $starttime = $mtime;
;?>



<!--  this code at the bottom of the page -->
<?php
   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $endtime = $mtime;
   $totaltime = ($endtime - $starttime);
   echo "This page was created in ".$totaltime." seconds";
;?>

output
This page was created in 0.0027 seconds.

Friday, May 23, 2014

Multiple Drop Down out put one container

Following code very useful select one value of multi drop down (select) , show out put value define  container.

Js is pick this url: mootools-core-1.4.5-nocompat.js



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Multiple Drop Down out put one container</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">

<script type='text/javascript' src='mootools-core-1.4.5-nocompat.js'></script>
<script language="javascript">

function run(val) {


if(val==1)
{
document.getElementById("srt").innerHTML = document.getElementById("Ultra").value;
document.getElementsByName("Ultra2")[0].value="drop2";
document.getElementsByName("Ultra3")[0].value="drop3";
}
else if(val==2)
{
document.getElementById("srt").innerHTML = document.getElementById("Ultra2").value;
document.getElementsByName("Ultra")[0].value="drop1";
document.getElementsByName("Ultra3")[0].value="drop3";

}

else if(val==3)
{
document.getElementById("srt").innerHTML = document.getElementById("Ultra3").value;
document.getElementsByName("Ultra")[0].value="drop1";
document.getElementsByName("Ultra2")[0].value="drop2";

}
else{
document.getElementsByName("Ultra")[0].value="drop1";
document.getElementsByName("Ultra2")[0].value="drop2";
document.getElementsByName("Ultra3")[0].value="drop3";
}


}




</script>


</HEAD>

<BODY  onLoad="run()">


<table cellpadding="10" cellspacing="10" ><tr><td>
Drop1 <select id="Ultra" onchange="run(1)" name="Ultra" >  <!--Call run() function-->
     <option value="drop1">Select</option>
     <option value="1">text1</option>
     <option value="2">text2</option>
     <option value="3">text3</option>    
</select></td>
<td>
Drop2 <select id="Ultra2" onchange="run(2)" name="Ultra2" >  <!--Call run() function-->
     <option value="drop2">Select</option>
     <option value="4">text4</option>
     <option value="5">text5</option>
     <option value="6">text6</option>    
</select></td>
<td>

Drop3 <select id="Ultra3" onchange="run(3)" name="Ultra3" >  <!--Call run() function-->
     <option value="drop3">Select</option>
     <option value="7">text7</option>
     <option value="8">text8</option>
     <option value="9">text9</option>    
</select></td>
</tr></table>

<!-- main container Start -->
<div id="srt" style="padding:0 0 0 20px;">OutPut Area </div>
<!-- main container End -->

</BODY>
</HTML>

Saturday, April 26, 2014

Drop down content with onclick using javascript

This is very simple drop down code using html, javascript,css. This code opening/closing container  every drop down onclick heading.


<!DOCTYPE html>
<html>
    <head>
        <meta charset='utf-8'/>
        <title>Drop down content with onclick using javascript</title>
        <style>
            * { margin:0; padding:0; font-family:sans-serif; }

            body { width:650px; }

            .drop_h, li, h2 { margin-bottom:15px; }

            .drop_h {
                text-decoration:none;
                font-size:16px;
                display:block;
            }

            .content {
                display:none;
            }

            #improved li {
                position:relative;
                overflow:hidden;
            }
        </style>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script>
            $(document).ready(function(){
                $('#original .drop_h').click(function(e){
                    e.preventDefault();
                    $(this).closest('li').find('.content').slideToggle();
                   
                   
                   
                   
                   
                   
                   
                   
                });

                $('#improved .drop_h').click(function(e){
                    e.preventDefault();
                    $(this).closest('li').find('.content').not(':animated').slideToggle();
                });
            });
        </script>
    </head>
    <body>
        <h2>Drop Down Simple Script</h2>
        <ul id='original'>
            <li>
                <a href='#' class='drop_h'>Heading 1</a>
                <div class='content'>
                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
            <li>
                <a href='#' class='drop_h'>Heading 2</a>
                <div class='content'>
                    <p>PHP5 introduces a special function called '__autoload()' (the word 'autoload' prefixed by double underscores). This function allows you to avoid writing a long list of includes at the top of your script by defining them inside this function. So you can automatically load object files when PHP encounters a class that hasn't been defined </p>

                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
           
        </ul>
        <h2>Animated Drop Down </h2>
        <ul id='improved'>
            <li>
                <a href='#' class='drop_h'> Improved Heading 1</a>
                <div class='content'>
                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
            <li>
                <a href='#' class='drop_h'>Improved Heading 2</a>
                <div class='content'>
                    <p>PHP5 introduces a special function called '__autoload()' (the word 'autoload' prefixed by double underscores). This function allows you to avoid writing a long list of includes at the top of your script by defining them inside this function. So you can automatically load object files when PHP encounters a class that hasn't been defined </p>

                    <p>PHP5 introduces 'interfaces' . An interface defines the methods a class must implement. All the methods defined in an interface must be public. An interface helps you design common APIs. It is not designed as a blueprint for classes, but just a way to standardize a common API. A big advantage of using interfaces is that a class can implement any number of interfaces. You can still only 'extend' on parent class, but you can 'implement' an unlimited number of interfaces.</p>
                </div>
            </li>
           
        </ul>
    </body>
</html>

Thursday, April 17, 2014

Create HTML form using Object Oriented Programming And Systems

Following code easy to understand made html form using php oops concept

<?php
/***** HTML Form Create using OOP *******/

class form {

    //Input Attributes
    public    $type;
    public    $name;
    public    $value;
    public  $text;
    public $opttext;
    //Select Methods                       
    public $optValues = array();
    public $starttag;
    public $action;
    public $method;
    /* form tag */
    function formtag() {
      if($this->starttag=='true') {
          echo "<form action='". $this->action ."' method='". $this->method ."'>";
      }    else {
          echo "</form>";
      }         
    }
               
     //Input Fields
     function input() {   

        if($this->type=='text') {
                echo $this->text."<input type='". $this->type ."' name='". $this->name ."' value='". $this->value ."'> ";                                                                  
        } else if ( $this->type=='select') {
                echo $this->text."<select name='". $this->name ."'> ";
                for($i=0; $i< count($this->optValues);$i++ ) {
                    echo "<option value='". $this->optValues[$i] ."'>". $this->optValues[$i] ." </option> ";
                }
                echo "</select>";                       
        } else if($this->type=='radio' || $this->type=='checkbox') {       
                echo $this->text."<input type='". $this->type ."' name='". $this->name ."' value='". $this->value ."'>".$this->opttext;                                                                  
        } else if($this->type=='button' || $this->type=='submit' || $this->type=='reset') {                           
                echo "<input type='". $this->type ."' name='". $this->name ."' value='". $this->value ."'> ";                                                                  
        }


else if($this->type=='textarea') {                           
                echo $this->text."<textarea wrap='virtual'  name='". $this->name ."'>". $this->value ."</textarea>";                                                                  
        }

       
       
        else {
           echo "Please enter the type";
        }               
     }//method end. 
   
    function br() {
            echo "<br />";
    }//if end                           
   
}
$formInputs = new form;
       
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<TITLE>OOPs HTML Form</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</head>
<body>
<h1>HTML Form using oops </h1>

<?php

    $formInputs->starttag='true';
    $formInputs->action ='';
    $formInputs->method ='post';   
    $formInputs->formtag();
       
    $formInputs->text  = "Name";
    $formInputs->type  = "text";
    $formInputs->name  = "";
    $formInputs->value =    "";   
    $formInputs->input();
    $formInputs->br();
   
    $formInputs->text  = "DOB";
    $formInputs->type  = "text";
    $formInputs->name  = "";
    $formInputs->value =    "";   
    $formInputs->input();
    $formInputs->br();
   
    $formInputs->text    = "Gender";
    $formInputs->type    = "radio";
    $formInputs->name    = "gender";
    $formInputs->opttext = "Male";   
    $formInputs->input();
   
   
    $formInputs->text    = "";
    $formInputs->type    = "radio";
    $formInputs->name    = "gender";
    $formInputs->opttext = "Female";   
    $formInputs->input();   
    $formInputs->br();       
   
    $formInputs->text  = "Country";
    $formInputs->type  = "select";
    $formInputs->name  = "country";   
    $formInputs->optValues[] = 'India'; $formInputs->optValues[] = 'UK'; $formInputs->optValues[] = 'usa';
    $formInputs->optValues[] = 'Srilanka'; $formInputs->optValues[] = 'Bhutan';      $formInputs->optValues[] = 'Tibet';
    $formInputs->input();
    $formInputs->br();
   



    $formInputs->text    = "Message";
    $formInputs->type    = "textarea";
    $formInputs->name    = "message";
    $formInputs->input();   
    $formInputs->br();       





    $formInputs->type  = "submit";
    $formInputs->name  = "";
    $formInputs->value = "Submit";   
    $formInputs->input();
    //$formInputs->br();
   
$formInputs->type  = "reset";
    $formInputs->name  = "";
    $formInputs->value = "Clear";   
    $formInputs->input();
    $formInputs->br();


    $formInputs->starttag='false';
    $formInputs->formtag();
?>       
</body>
</html>







 

Wednesday, April 9, 2014

Onclick changed top and bottom value using html and simple javascript

Onclick change value of two places at time using simple javascript and html. Please Use below code.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Onclick changed top and bottom value using html and simple javascript  </TITLE>

<script language="javascript">

function toggle(id) {

for(i=1;i<4;i++)
{
var obj = 'tab'+i;
var obj1 = 'tb'+i;

if(i==id)
{
document.getElementById(obj).style.display = 'block';
document.getElementById(obj1).className="selected" ;
}
else
{
document.getElementById(obj).style.display = 'none';
document.getElementById(obj1).className = '';
}
}
}

</script>





</HEAD>

<BODY>
<div style="display:block;" class="tab-heading" id="tab_head">Display tab top value 1<br></div>

<div class="tabcontainer">

<div class="shadetabs">

<div id="tb1" class="selected"><br><a style="cursor:pointer;color:#0000FF;" onClick="changeHeading(1); toggle(&#39;1&#39;); return false;" >Click tab1</a>&nbsp;and &nbsp;
<div id="tb2" class=" " ><a style="cursor:pointer;color:#0000FF;" onClick="changeHeading(2); toggle(&#39;2&#39;); return false;">Click tab2</a><br></div></div>

</div>

<script language="javascript">
function changeHeading(tab)
{
if(tab==1)
document.getElementById('tab_head').innerHTML = 'Display tab top value 1';

if(tab==2)
document.getElementById('tab_head').innerHTML = 'Display tab top value 2';

}
</script>
<!-- section display  all hotels  start here -->

<div style="display:block;" id="tab1">
<br> Display tab bottom value1
</div>


<div style="display:none;" id="tab2"><br> Display tab bottom  value 2 </div>

</div>
</BODY>
</HTML>

Wednesday, April 2, 2014

Simple Responsive Form design using html css

it is very useful code of Responsive Form design using html css. Following code use it.

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Simple Responsive Form</title>
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="author" content="Vikash Gupta">

   
<meta name="viewport" content="width=device-width; initial-scale=1.0;">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style type="text/css">
body {
    font-family: Arial, Verdana, Helvetica, sans-serif;
    font-size:16px;
    line-height:1.3em;
    color:#555555;
    font-weight:normal;
    background: url(../img/bg-body.jpg) repeat scroll left top;
}
a {color: #634e00;text-decoration:underline;}
a:hover {text-decoration:none;color: #634e00;}
p, ul, ol {font-size:0.9375em;}
h1, h2, h3, h4, h5, h6, p, ul, ol, dl {margin:0.7em 20px 0.9em 20px;}
h1, h2, h3, h4, h5, h6 {font-family: 'liberation-sans-1','liberation-sans-2', Arial, Verdana, Helvetica, sans-serif;font-weight:normal;color:#322801;line-height:1.2em;}
h1 {font-size:1.875em;color:#58471E;}
h2 {font-size:1.5em;color:#58471E;}
h3 {font-size:1.375em;}
h4 {font-size:0.9375em;}
h5 {font-size:0.9375em;}
img {
    -ms-interpolation-mode: bicubic;/*IE only*/
    max-width: 100%;
    width:auto;
    height:auto;
}




/************************************************************************************
Form styles
*************************************************************************************/
input,
textarea,
select {
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    -khtml-border-radius: 4px;
    border-radius: 4px;
    font-family: Arial, Verdana, Helvetica, sans-serif;
    font-size:15px;
    -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1) inset;
    webkit-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.1);
    -moz-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.1);
    box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.1);
    background:#f9f2e2;
}

input:focus,
textarea:focus,
select:focus {
    background:#eee1c3;
}
/* footer mailing list subscribe form*/
form#subForm input {
    padding:8px 5px;
    border: none;
    color:#20251c;
    width:95%;
}
form#subForm label {
    display:block;
    padding-bottom:0.25em;
}
form label.error  {
    display:block;
    padding-top:0.25em;
    color:#e45c37;
    clear:both;
    text-transform:uppercase;
    font-size:0.75em;
}


/* all main page form styles*/
fieldset {
    border:1px solid #ede0c0;
    margin:20px;
    padding-bottom:15px;
    -moz-border-radius: 6px;
    -webkit-border-radius: 6px;
    -khtml-border-radius: 6px;
    border-radius: 6px;
    background: #fff url(../img/bg-body.jpg) repeat scroll left top;
    color:#58471E;   
}
legend {
    padding:10px;
    margin-left:10px;
    font-size:1.375em;
    color:#58471E;
}
form ol {
    margin:0;
    overflow:hidden;
    margin-left:20px;
    margin-right:20px;
}
form ol li {
    float:left;
    display:inline;
    width:100%;
    margin-right:2.5%;
    margin-bottom:0.5em;
}
form ol li:nth-child(2n) {
    margin-right:0;
    /*margin-left:2.5%;*/
}
form ol li.longdesc {
    float:left;
    display:inline;
    width:100%;
}
form ol li.longdesc:nth-child(2n) {
    margin-left:0;
}
form ol li.longdesc input,
form ol li textarea {
    width:95%;
    margin-right:2.5%;
}

form ol li input {
    width:47.5%;
    margin-right:2.5%;
}



form ol li select {
    width:96%;
    margin-right:2.5%;
}


form ol li table {
/*padding:5px;*/
margin:10px 0 0 0;;
}



form ol label {
    display:block;
    margin-bottom:6px;
}
form ol label a {
color:#0033CC;
}



form ol li input,
textarea,
select {
    border:none;
    padding:10px 5px;
    /*background:#f1e1bf;*/
}
form ol li select#Enquiry {
    width:100%;
}
form ol li input {
    width:95%;
}
form em {
    font-style:normal;
}

form label small {
    display:block;
    font-size:13px;
    font-style:italic;
}

/* button style */
button {
    background:#f9d835; /* default background for browsers without gradient support */
    background:-webkit-gradient(linear, left top, left bottom, from(#f9d835), to(#f3961c));
    background:-moz-linear-gradient(top, #f9d835, #f3961c);
    background:-o-linear-gradient(top, #f9d835, #f3961c);
    border:none;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight:normal;
    padding:6px 12px;
    -moz-border-radius: 8em;
    -webkit-border-radius: 8em;
    -khtml-border-radius: 8em;
    border-radius: 8em;
    margin-top:15px;
}
button:hover {
    background:#f9d835;
    cursor: pointer;
}

input[type="submit"]
{
    background:#A26008; /* default background for browsers without gradient support */
    background:-webkit-gradient(linear, left top, left bottom, from(#A26008), to(#A26008));
    background:-moz-linear-gradient(top, #A26008, #A26008);
    background:-o-linear-gradient(top, #A26008, #A26008);
    border:none;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight:normal;
    padding:6px 12px;
    -moz-border-radius: 8em;
    -webkit-border-radius: 8em;
    -khtml-border-radius: 8em;
    border-radius: 8em;
    margin-top:15px;
}

input[type="reset"]
{
    background:#A26008; /* default background for browsers without gradient support */
    background:-webkit-gradient(linear, left top, left bottom, from(#A26008), to(#A26008));
    background:-moz-linear-gradient(top, #A26008, #A26008);
    background:-o-linear-gradient(top, #A26008, #A26008);
    border:none;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    font-weight:normal;
    padding:6px 12px;
    -moz-border-radius: 8em;
    -webkit-border-radius: 8em;
    -khtml-border-radius: 8em;
    border-radius: 8em;
    margin-top:15px;
}





/*form php error styles */
#formerror {
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    -khtml-border-radius: 4px;
    border-radius: 4px;
    background:#f9f0ee;
    margin:20px;
    border:1px solid #f9b3a4;
}
#formerror p {
    color:#E45C37;   
}





</style>
</head>
<body>
<h1>Simple Responsive Form</h1>

   
      <form name="form1" method="POST" action="#" id="form1" onSubmit="return validation_form();" autocomplete="off">

        <p>Please note that fields marked <em>(*)</em> must be completed to allow us to process your booking.</p>
       
        <fieldset>
        <legend>Your Requirements</legend>
              <ol>
        <li>
            <label for="Name">Name of fruits: <em>(*)</em></label>


<select id="fruits" name="fruits"  class="required">
<option value="">--Select fruits--</option>

<option value="apple">Apple</option>
<option value="apricot">Apricot</option>
<option value="banana">Banana</option>
<option value="carrot">Carrot</option>
<option value="grape">Grape</option>
<option value="mango">Mango</option>

</select>
          </li>
         
   <li>
            <label for="rooms">No. of Packets <em>(*)</em></label>
      <select   id="packets" name="packets">
      <option value="">--Select packets--</option>
<option  value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>

</select>
          </li>
  
 
         
        </ol>
        </fieldset>
       
                 <fieldset>
        <legend>Your Order Details:</legend>
        <ol>
          <li>
            <label for="Name">Full Name: <em>(*)</em></label>
            <input type="text" name="Name" id="Name" value="" class="required">
          </li>
          <li>
            <label for="Surname">Email: <em>(*)</em></label>
            <input type="text" name="Surname" id="Surname" value="" class="required">
          </li>
         
         
          <li>
            <label for="phone">Phone: <em>(*)</em></label>
            <input type="text" name="phone" id="phone" value="" class="required">
          </li>
         
           <li class="longdesc">
            <label for="address">Address:</label>
            <textarea name="address" id="address" rows="6" cols="40"></textarea>
          </li>
         
              <li class="longdesc">
            <label for="message">Comment / Suggestion:</label>
            <textarea name="message" id="message" rows="6" cols="40"></textarea>
          </li>
      
         
         
        </ol>
        </fieldset>
       <p> <input type="submit"   value="Order request"  name="submit">&nbsp;&nbsp;<input  type="reset" value="Clear " class="button_plan"  onClick="window.location.reload()"/> </p>
      </form>
      <!-- form ends -->



</body>
</html>