wonderphp

Some wonder in PHP


wonderphp

  • equal height elements

    function equalHeight(group) { var tallest = 0; group.each(function() { var thisHeight = $(this).height(); if(thisHeight > tallest) { tallest = thisHeight; } }); group.height(tallest); } equalHeight($(“.commonclass”)); Continue reading

  • Hour dropdown

    <select id=’time’> <?php for($i = 1; $i <= 24; $i++): ?> <option value=”<?= $i; ?>”><?= date(“h.iA”, strtotime(“$i:00″)); ?></option> <?php endfor; ?> </select> <select id=’time’> <option value=”1″>01.00AM</option> <option value=”2″>02.00AM</option> <option value=”3″>03.00AM</option> <option value=”4″>04.00AM</option> <option value=”5″>05.00AM</option> <option value=”6″>06.00AM</option> <option value=”7″>07.00AM</option> <option value=”8″>08.00AM</option> <option value=”9″>09.00AM</option> <option value=”10″>10.00AM</option> <option value=”11″>11.00AM</option> <option value=”12″>12.00PM</option> <option value=”13″>01.00PM</option> <option value=”14″>02.00PM</option> <option value=”15”>03.00PM</option> <option… Continue reading

  • Convert object to array and Vice versa

    function objectToArray($d) { if (is_object($d)) { // Gets the properties of the given object // with get_object_vars function $d = get_object_vars($d); } if (is_array($d)) { /* * Return array converted to object * Using __FUNCTION__ (Magic constant) * for recursive call */ return array_map(__FUNCTION__, $d); } else { // Return array return $d; } } Continue reading

  • Maintain display order field in php

    Remember I am considering following two parameters table name – DisplayOrder column name to reorder = O_nbr if you need to shift the O_nbr (order number) from 10 to 1 you just need to call the method as select UpdateOrder(10,1); // it will return you the proper message either updated or not.. or whatever the… Continue reading

  • Sending HTML Mail via PHP

    <?php require_once "Mail.php"; require_once "Mail/mime.php"; // see http://pear.php.net/manual/en/package.mail.mail-mime.php // for further extended documentation on Mail_Mime $from = "Web Master “; $to = “Nobody “; $subject = “Test HTML email using PHP Pear w/ SMTP\r\n\r\n”; $text = “This is a text test email message”; $html = “This is an html test email message This Is A… Continue reading

  • Installing PEAR Mail for PHP On Ubuntu

    Just run these commands in terminal sudo apt-get install php-pear sudo pear install mail sudo pear install Net_SMTP sudo pear install Auth_SASL sudo pear install mail_mime and if you want to check that its running or not try code for send mail at Sending HTML Mail via PHP Continue reading

  • Restrict space at first position in textbox using jquery/javascript

    $(“input”).on(“keypress”, function(e) { if (e.which === 32 && !this.value.length) e.preventDefault(); }); Continue reading

  • html page form enlarge in mobile device

    $(‘input[type=search]’).on(‘focus’, function(){ // replace CSS font-size with 16px to disable auto zoom on iOS $(this).data(‘fontSize’, $(this).css(‘font-size’)).css(‘font-size’, ’16px’); }).on(‘blur’, function(){ // put back the CSS font-size $(this).css(‘font-size’, $(this).data(‘fontSize’)); }); Continue reading

  • display all database queries made by WordPress

    The SAVEQUERIES definition saves the database queries to an array and that array can be displayed to help analyze those queries. The information saves each query, what function called it, and how long that query took to execute. NOTE: This will have a performance impact on your site, so make sure to turn this off… Continue reading

  • Get geolocation contry,city,region_name using js

    function getcurrentlocation() { theUrl=”http://freegeoip.net/json/”+myIP(); xmlhttp.open(‘get’, theUrl, true); xmlhttp.onreadystatechange = ReplyUrl; xmlhttp.send(null); } function ReplyUrl() { if(xmlhttp.readyState == 4) { if(xmlhttp.responseText != “”) { var response = xmlhttp.responseText; var parsedJSON = eval(‘(‘+response+’)’); var location; location = document.getElementById(‘location’).value; console.log(parsedJSON.city+”, “+parsedJSON.region_name+”, “+parsedJSON.country_name); if(parsedJSON.city) location =location+”,”+parsedJSON.city; if(parsedJSON.region_name) location =location+”,”+parsedJSON.region_name; if(parsedJSON.country_name) location =location+”,”+parsedJSON.country_name; console.log(location); document.getElementById(‘location’).value = location; } else {… Continue reading

About Me

A seasoned web developer with over 14 years of experience, has honed a craft across a variety of frameworks and platforms.

Newsletter