Top Questions

  • 2.9 Years

    • Category : Html
    • Location : Chandigarh
    • Posted On : Jan 21, 2016
    <form action="demo_form.asp">
    Password: <input type="password" name="pw" pattern=".{6,}" title="Six or more characters">
    <input type="submit">
    </form>

     

  • 5.11 Years

    • Category : Wordpress
    • Location : Mohali
    • Posted On : Feb 20, 2018

    The hook allows meta box registration for any post type. Passes two parameters: $post_type and $post. Note: You can also use add_meta_boxes_{post_type} for best practice, so your hook will only run when editing a specific post type. This will only receive 1 parameter - $post.

    Add this to functions.php
    add_action( 'add_meta_boxes', 'gp_add_meta_boxes' );
    function gp_add_meta_boxes() {
        add_meta_box( 'gp_product', 'Products Options', 'gp_products_callback', 'review', 'normal', 'high' );
    }
    
    function gp_products_callback( $post ) {
        $fname = get_post_meta( $post->ID, 'fname', true );
    
    // reset choices
    	$field['choices'] = array();
    	
    	$users = get_users();
    	?>
    	<select name="cust_user"></select>
    	<?php
    	foreach ($users as $user) {
    		$field[ $user->ID ] = $user->display_name;
    	}
    
        ?>
        <p>First Name: <input type="text" name="fname" value="<?php echo $fname; ?>"></p>
        <?php
    }
     
  • 5.11 Years

    • Category : Htaccess
    • Location : Mohali
    • Posted On : Dec 15, 2015

    Speed-up your website with these simple .htaccess tricks

    # Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
    RewriteBase /
    
    # BEGIN Cache-Control Headers
    <ifModule mod_headers.c>
     <filesMatch ".(ico|jpe?g|png|gif|swf)$">
       Header set Cache-Control "public"
     </filesMatch>
     <filesMatch ".(css)$">
       Header set Cache-Control "public"
     </filesMatch>
     <filesMatch ".(js)$">
       Header set Cache-Control "private"
     </filesMatch>
     <filesMatch ".(x?html?|php)$">
       Header set Cache-Control "private, must-revalidate"
     </filesMatch>
    </ifModule>
    # END Cache-Control Headers
    
    <ifmodule mod_expires.c>
    <Filesmatch "\.(jpg|jpeg|png|gif|js|css|swf|ico|woff|mp3)$">
        ExpiresActive on
        ExpiresDefault A2592000
    </Filesmatch>
    </ifmodule>
    
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Feb 12, 2017

    JQuery Ajax form using boostrap validation

     $(document).on('submit','#formid',function(){
     $(this).formValidation({
                                framework: 'bootstrap',
                                fields: {
                                    name: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The name is required'
                                            }
                                        }
                                    },
                                    email: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The email is required'
                                            }
                                        }
                                    },
                                    password: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The password is required'
                                            }
                                        }
                                    },
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                               var Formdata=$(this).serialize();
                                $.ajax({
                                    type: "POST",
                                    url: '', //add page url here
                                    data: Formdata, //send data from here,
                                    success: function(data) {
                                        alert(data);
                                    }
                                });
                            });
                     });
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jan 4, 2017

    Easy Multiple Image Using Codeigniter.

    if($_FILES['filename']['name']!='')
     {
           $image=array();
           $counts = count($_FILES['filename']['name']);
           $config['upload_path'] = APPPATH.'uploads/'; //create upload folder in application
                                                        // Give permission -R 777 to upload folder 
           $config['allowed_types'] = '*';
           $files = $_FILES;
           for($i=0; $i<$counts; $i  )
            {       
               if($_FILES['filename']['name'][$i]!='')
     { 
           $_FILES['filename']['name']= time().$files['filename']['name'][$i];
           $_FILES['filename']['type']= $files['filename']['type'][$i];
           $_FILES['filename']['tmp_name']= $files['filename']['tmp_name'][$i];
           $_FILES['filename']['error']= $files['filename']['error'][$i];
           $_FILES['filename']['size']= $files['filename']['size'][$i];
           $this->load->library('upload', $config);
           $this->upload->initialize($config);
           $upload= $this->upload->do_upload('familypicture');
           if($upload){
          $uu=$this->upload->data();
                $image[] =$uu['file_name'];
       }
             }
             }
       $fileToUpload = implode('|',$image);
    }
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Jan 5, 2016
    $num_rec_per_page=4;
        if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
        $start_from = ($page-1) * $num_rec_per_page; 
    $q="select * from tablename LIMIT $start_from, $num_rec_per_page";
    $res=mysql_query($q);
    while($r=mysql_fetch_array($res))
    {
    //Enter Your code
    }
      <ul class="pagination">
            <?php 
             $sql = "SELECT * FROM `tablename`"; 
               $rs_result = mysql_query($sql); //run the query
               $total_records = mysql_num_rows($rs_result);  //count number of records
               $total_pages = ceil($total_records / $num_rec_per_page); 
             echo "<li><a href='&page=1'>".'&laquo;'."</a></li> "; // Goto 1st page  
            for ($i=1; $i<=$total_pages; $i++) { 
              echo "<li><a href='&page=".$i."'>".$i."</a></li> "; 
          }; 
             echo  "<li><a href='&page=$total_pages'>".'&raquo;'."</a></li> "; // Goto last page
    ?>
    </ul>
    
  • 5.11 Years

    • Category : Magento
    • Location : Mohali
    • Posted On : Jul 7, 2016

    Magento SEO - How to add Magento Canonical Meta Tag

    Step 1: Login your Magento Admin Panel

    Step 2: Go to  System > Configuration

    Step 3: In the left menu, choose Catalog >> Search Engine Optimizations
    • In the "Use Canonical Link Meta Tag for Categories" choose "Yes"
    • In the "Use Canonical Link Meta Tag for Products" choose "No"

    Step 4:  Save the changes
     
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Mar 16, 2016
    <?php 
    include('config.php'); //connection file
    //header to give the order to the browser
    header('Content-Type: text/csv');
    header('Content-Disposition: attachment;filename=user.csv');
    //select table to export the data
    $select_table=mysql_query('select `email` from login');
    $rows = mysql_fetch_assoc($select_table);
    
    if ($rows)
    {
    getcsv(array_keys($rows));
    }
    while($rows)
    {
    getcsv($rows);
    $rows = mysql_fetch_assoc($select_table);
    }
    
    // get total number of fields present in the database
    function getcsv($no_of_field_names)
    {
    $separate = '';
    
    
    // do the action for all field names as field name
    foreach ($no_of_field_names as $field_name)
    {
    /*if (preg_match('/\\r|\\n|,|"/', $field_name))
    {
    $field_name = '' . str_replace('', $field_name) . '';
    }*/
    echo $separate . $field_name;
    
    //sepearte with the comma
    $separate = ',';
    }
    
    //make new row and line
    echo "\r\n";
    }
    ?>

     

  • 2.9 Years

    • Category : Mysql
    • Location : Chandigarh
    • Posted On : Mar 31, 2016

    This code resolve special character problem during fetch data from database.just copy and paste code where you create your connection.

    //copy in config file
    mysql_set_charset('utf8');
     
  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Oct 7, 2017

    YouTube video Link may be encountered in a variety of formats:

    1.     latest short format: http://youtu.be/NLqAF9hrVbY
    2.     iframe: http://www.youtube.com/embed/NLqAF9hrVbY
    3.     iframe (secure): https://www.youtube.com/embed/NLqAF9hrVbY
    4.     object param: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
    5.     object embed: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
    6.     watch: http://www.youtube.com/watch?v=NLqAF9hrVbY
    7.     users: http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo
    8.     ytscreeningroom: http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I
    9.     any/subdomain/too: http://gdata.youtube.com/feeds/api/videos/NLqAF9hrVbY
    10.     more params: http://www.youtube.com/watch?v=spDj54kf-vY&feature=g-vrec
    11.     query may have dot: http://www.youtube.com/watch?v=spDj54kf-vY&feature=youtu.be
    12.     nocookie domain: http://www.youtube-nocookie.com
    function convertYoutube($string) {
    	$pattern='~(?#!js YouTubeId Rev:20160125_1800)
            # Match non-linked youtube URL in the wild. (Rev:20130823)
            https?://          # Required scheme. Either http or https.
            (?:[0-9A-Z-] \.)?  # Optional subdomain.
            (?:                # Group host alternatives.
              youtu\.be/       # Either youtu.be,
            | youtube          # or youtube.com or
              (?:-nocookie)?   # youtube-nocookie.com
              \.com            # followed by
              \S*?             # Allow anything up to VIDEO_ID,
              [^\w\s-]         # but char before ID is non-ID char.
            )                  # End host alternatives.
            ([\w-]{11})        # $1: VIDEO_ID is exactly 11 chars.
            (?=[^\w-]|$)       # Assert next char is non-ID or EOS.
            (?!                # Assert URL is not pre-linked.
              [?=& %\w.-]*     # Allow URL (query) remainder.
              (?:              # Group pre-linked alternatives.
                [\'"][^<>]*>   # Either inside a start tag,
              | </a>           # or inside <a> element text contents.
              )                # End recognized pre-linked alts.
            )                  # End negative lookahead assertion.
            [?=& %\w.-]*       # Consume any URL (query) remainder.
            ~ix';
    	preg_match_all($pattern,$string,$match);
    	$res=array();
    	$res['youtube']=$match;
    	$res['text']=preg_replace($pattern, '', $string);
    	return $res;
    }
    $text = "php find youtube link in string. How do I find all YouTube video ids in a string using a regex https://www.youtube.com/watch?v=ItTjUrTZ_JE Find youtube Link in PHP string and Convert it into embed code? Well, you need to filter out the youtube links first and put them into an string. Next you need to find out the youtube links of the url which is very easy. Use this script:";
    
    $all=convertYoutube($text);
    
    //print_r($all);
    
    echo $all['youtube'][1][0];	
    // ItTjUrTZ_JE
    
    echo $all['youtube'][0][0];	
    // https://www.youtube.com/watch?v=ItTjUrTZ_JE
    
    echo $all['text'];	
    // php find youtube link in string. How do I find all YouTube video ids in a string using a regex Find youtube Link in PHP string and Convert it into embed code? Well, you need to filter out the youtube links first and put them into an string. Next you need to find out the youtube links of the url which is very easy. Use this script: