Get Website Lowest price!

Wordpress Experts!


php up to date

Examples php programs

Examples php programs

// capture the start time
$start_time = microtime(true);
// do some stuff
// ...
// display how long the script took
echo "execution took: ".
        (microtime(true) - $start_time).
        " seconds.";

Ajax retrieve data onchange input:

<script type="text/javascript">

        $(document).ready(function () {

            // if user chooses an option from the select box...
            $("#cid").change(function () {
                // get selected value from selectbox with id #department_list
                var cusno = $(this).val();

                    url: "functions/get_name.php",
                    data: "q=" + cusno,
                    dataType: "json",

                    // if successful
                    success: function (response, textStatus, jqXHR) {

                        // no teachers found -> an empty array was returned from the backend
                        if (response.customer_name.length == 0) {
                            $('#result').html("nothing found");
                        else {
                            // backend returned an array of names
                            var list = $("#list");

                            // remove items from previous searches from the result list

                            // append each teachername to the list and wrap in <li>
                            $.each(response.customer_name, function (i, val) {
                                //list.append($("<li>" + val + "</li>"));

            // if anywhere in our application happens an ajax error,this function will catch it
            // and show an error message to the user
            $(document).ajaxError(function (e, xhr, settings, exception) {
                $("#error").html("<div class='alert alert-warning'> Uups, an error occurred.</div>");



Use of PHP group_concat

 If you wants to display date wise records in a single row you need group_concat. 

Table 1: customer                          table 2: customer_trasaction
customer_id                                     id
customer_name                                customer_id
customer_city                                   paid_date
Now we need to get all the customer details transaction in a month datewise in one row per customer

$query=mysql_query("Select customer.customer_id,customer.customer_name, group_concat(customer_transaction.paid_amount) from customer left join customer_transaction on customer.customer_id=customer_trasaction.customer_id group by customer.customer_id where customer_transaction.paid date between '2014-09-01' and '2014-09-30' ");


Mail send 

  $pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i";
       if (preg_match($pattern, trim(strip_tags($_POST['email']))))
           $cleanedFrom = trim(strip_tags($_POST['email']));
       } else
           return "The email address you entered was invalid. Please try again!";
  $res = $name;
  $res .= $contact."\r\n";
  $res .= $domain."\r\n";
  $res .= $skypeid."\r\n";
  $res .= $message."\r\n";
  $from = $email."\r\n";
  $headers = "From: $from \r\n";
  $header .= "MIME-Version: 1.0\r\n";
  $header .= "Content-type: text/html\r\n";
  if(mail($to, $subject, $res, $headers))
       echo "<span id='messageBack'>Message successfully sent</span>";

    } else{
        echo "<span id='messageBack'>Your message wasn't sent. Please try again later.</span>";