Skip to main content

Posts

Showing posts from March, 2016

Php Date function parameters

    Php Date and time parameters <?php // Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the // Mountain Standard Time (MST) Time Zone $today  =  date ( "F j, Y, g:i a" );                  // March 10, 2001, 5:16 pm $today  =  date ( "m.d.y" );                          // 03.10.01 $today  =  date ( "j, n, Y" );                        // 10, 3, 2001 $today  =  date ( "Ymd" );     ...

How to use jquery price slider min and max price

How to use jquery price slider min and max price Solution 1- <?php if(isset($_POST['isvaluesubmit'])) { $minprice =  $_POST['minPrice']; $maxprice = $_POST['maxPrice']; } ?> <div class="row">                 <div class="col-lg-12">                   <h4 data-toggle="" data-target="#cost">Cost&apos;s</h4>                   <div class="">                     <p>                       <label for="amount">Price range:</label>          ...

How to scroll bottom to div jquery javascript

How to scroll bottom to  div jquery javascript Solution 1 -  this is the simple script for scroll bottom to a div using jquery or javascript With Javascript var objDiv = document.getElementById("sinlgecontainerid"); objDiv.scrollTop = objDiv.scrollHeight; With jQuery var d = $ ( '#div1' ); d . scrollTop ( d . prop ( "scrollHeight" ));   Or animated: $ ( "#div1" ). animate ({ scrollTop : $ ( '#div1' ). prop ( "scrollHeight" )}, 1000 ); Solution 2 -   You could set an interval to update the element's scrollTop to its scrollHeight every couple of seconds window . setInterval ( function () { var elem = document . getElementById ( 'data' ); elem . scrollTop = elem . scrollHeight ; }, 5000 );

Add custom field in woocommerce registration form

Add custom field in woocommerce registration form add_action( 'register_form', 'adding_custom_registration_fields' ); function adding_custom_registration_fields( ) {     //lets make the field required so that i can show you how to validate it later;     $city = empty( $_POST['city'] ) ? '' : $_POST['city'];         ?>     <div class="form-row form-row-wide">         <label for="reg_city"><?php _e( 'city', 'woocommerce' ) ?><span class="required">*</span></label>         <input type="text" class="input-text" name="city" id="reg_city" size="30" value="<?php echo esc_attr( $city ) ?>" />     </div>     <?php } Updating use meta after registration successful registration add_action('woocommerce_created_customer','adding_extra_reg_fields'); function adding_extra_...

Use Google Map without key for dynamic address

Use Google Map without key for dynamic address <?php $address = "Mavviya Nagar Jaipur"; $address = str_replace(" ", "+", $address); $json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false"); $json = json_decode($json); $lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'}; $long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'}; $aLocation = array("title" => 'title',"content" => 'Content',"lat" => $lat,"lon" => $long); $aLocation = json_encode($aLocation); ?> <div id="map" style="width:500px;height:400px;"></div> <script> var aLocation = <?php echo $aLocation; ?>; function initMap() {     myLatLng = {lat: aLocation['lat'], lng: aLocation['lon']};     ...

Custom Search Page with search by location Wordpress

Step 1 First create a form into header file or where you want to show your form ex(header.php) or you can create a custom search form in wordpress like this. <form method="get" id="advanced-searchform" role="search" action="<?php echo esc_url( home_url( '/' ) ); ?>">       <input type="hidden" name="search" value="advanced">     <select name="citysearch" id="search" class="themebtnsearch">         <option value="City1"><?php _e( 'City1', 'textdomain' ); ?></option>         <option value="City2"><?php  _e( 'City2', 'textdomain' ); ?></option>     </select>     <input type="text" value="" placeholder="<?php _e( 'Type the Product Name', 'textdomain' ); ?>" name="productname" class="home_search...

PHP Jquery short codes functions

1. How to convert integer number into float and change pattern Ans. <?php $a = 2000; $your_val=  number_format($a/100,2,'.',','); echo $your_val; //output 20.00 ?> 2.How to use php variable into jquery with if condition Solution <script> $(document).ready(function(){ var limitvalue = '<?php if(isset($_GET['limitof'])) { echo  $_GET['limitof']; }else { echo 5; }  ?>'; $(".slctboxval").val(limitvalue); }); </script>

Create Simple Pagination in Php Mysql with ajax

Simple Pagination in Php Mysql and fetch data with ajax on your all_users.php <?php include_once "include/header.php"; ?> <?php $orderby = "ORDER BY id DESC"; $limitval = isset($_GET['limitof'])? $_GET['limitof']:5; $limitrow = "LIMIT 0,$limitval"; $count_total = $aClassDb->countRowAll("users"); $all_user = $aClassDb->getAllData('users',$orderby, $limitrow); $total_rows = ceil($count_total/$limitval); ?> <div class="row">     <div class="col-md-12">         <!-- BEGIN EXAMPLE TABLE PORTLET-->     <div class="portlet light portlet-fit bordered">         <div class="portlet-title">             <div class="caption">                 <i class="icon-settings font-red"></i>     ...

delete category and subcategory with products by category id in PHP MYSQL

How to delete category and subcategory with products by category id  in PHP MYSQL                                       or PHP Function to delete all category subcategory and products by category id     public function deleteSub($aTable,$cat_id) {         $aSql = "SELECT * FROM {$aTable} WHERE parent_id = ".$cat_id;         $results = mysqli_query($this->databaseLink,$aSql);         while($child = mysqli_fetch_array($results))         {             $this->deleteSub($aTable,$child["id"]);         }         $request = "DELETE FROM {$aTable} WHERE id = ...

Create custom Breadcrumbs in WORDPRESS

Create custom Breadcrumbs in WORDPRESS open your single.php and paste this code <?php $cats = get_the_category(); $cat_name = $cats[0]->slug; if($cat_name=="blog") { ?>  <h5><a href="<?php echo site_url(); ?>">home</a>/<a href="<?php echo site_url(); ?>/blog">blog</a>/<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5> <?php } elseif($cat_name=="pressrelease") { ?> <h5><a href="<?php echo site_url(); ?>">home</a>/<a href="<?php echo site_url(); ?>/press-release/">Press Release</a>/<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5> <?php } ?> * How to create custom breadcrumbs in wordpress * How ...

Get category and subcategory tree in PHP MySql

 How to Get category and subcategory tree in PHP MySql 1. How to get recursive category subcategory with  OOP PHP * Display the categories in a dropdown menu or select box function fetchCategoryTree ( $parent = 0 , $spacing = '' , $user_tree_array = '' ) {    if ( ! is_array ( $user_tree_array ) )      $user_tree_array = array ( ) ;    $sql = "SELECT `cid`, `name`, `parent` FROM `category` WHERE 1 AND `parent` = $parent ORDER BY cid ASC" ;    $query = mysql_query ( $sql ) ;    if ( mysql_num_rows ( $query ) > 0 ) {      while ( $row = mysql_fetch_object ( $query ) ) {        $user_tree_array [ ] = array ( "id" = > $row -> cid , "name" = > $spacing . $row -> name ) ;        $user_tree_array = fetchCategoryTree ( $row -> cid , $spacing . '&nbsp;&...