Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Friday, July 6, 2018

How to delete all rows from Table except First row using JavaScript | Javascript.

<table id="myTable" border="0" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <th></th>
            <th></th>
            <th></th>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
      
    </tbody>
</table>

<input type="button" id="" value="Delete Rows" onclick="DeleteRows()" />

<script type="text/javascript">
    function DeleteRows() {
        var rowCount = myTable.rows.length;
        for (var i = rowCount - 1; i > 0; i--) {
            myTable.deleteRow(i);
        }
    }
</script>

 

Sunday, April 15, 2018

How to zoom Image on hover image using jQuery | jQuery.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery spzoom Plugin Demo</title>
<link href="https://www.jqueryscript.net/demo/Simple-Image-Hover-Zoom-Plugin-With-jQuery-spzoom/jquery.spzoom.css" rel="stylesheet" type="text/css">
</head>
<body>
<li>
<a href="https://unsplash.it/600/450?image=319" title="@Naresh" data-spzoom>
    <img src="https://unsplash.it/200/150?image=319" alt="thumb"/>
</a>
</li>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://www.jqueryscript.net/demo/Simple-Image-Hover-Zoom-Plugin-With-jQuery-spzoom/jquery.spzoom.js"></script>
<script>
$(function() {
    $('[data-spzoom]').spzoom();
});
</script>
</body>
</html>



Thursday, March 1, 2018

How to find anchor tag from content and replace it and remove anchor tag from images in wordpress | Wordpress.

<?php 
    $phrase = get_the_content();
    // This is where wordpress filters the content text and adds paragraphs
    $phrase = apply_filters('the_content', $phrase);
   preg_match_all('/href="(http:\/\/[^\/"]+\/?)?([^"]*)"*/',$phrase, $matches);
   //echo '<pre>';
   //print_r($matches[2]);
    $i=0;
   $string="";
   foreach($matches[2] as $val){
    $value =substr($val,strpos($val,'/')+1);
     $slug=rtrim($value, "/");
     $getpostid = $wpdb->get_results( "SELECT ID FROM wp_posts
                       WHERE post_status= 'publish' AND post_name like '%$slug%'" );
                  $id=$getpostid[0]->ID;
 $ids[]="href=http://blog.saginfotech.com/app-single-post?id=".$id;
 }
 $newphrase = str_replace($matches[0],$ids, $phrase);
$content =str_replace('"','',$newphrase); 
  $content =
         preg_replace(array('{<a[^>]*><img}','{/></a>}'), array('<img','/>'), $content);
    echo  $content;
 ?>

How to show page content using page title in wordpress | Wordpress.

<?php
$page = get_page_by_title( 'About' );
$content = apply_filters('the_content', $page->post_content); 
echo $content;
?>

How to select all post data by category from database in php | Wordpress.

$querystr1 = "SELECT p.ID,p.post_title,t.term_id
FROM wp_posts p
LEFT JOIN wp_term_relationships rel ON rel.object_id = p.ID
LEFT JOIN wp_term_taxonomy tax ON tax.term_taxonomy_id = rel.term_taxonomy_id
LEFT JOIN wp_terms t ON t.term_id = tax.term_id where tax.term_taxonomy_id=5 ORDER BY p.ID DESC limit 1";
$pageposts1 = $wpdb->get_results($querystr1);
print_r($pageposts1);

How to select all post data from database in wordpress | Wordpress.

$querystr = "
    SELECT $wpdb->posts.* 
    FROM $wpdb->posts, $wpdb->postmeta
    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
   
  
    AND $wpdb->posts.post_status = 'publish' 
    AND $wpdb->posts.post_type = 'post'
    AND $wpdb->posts.post_date < NOW()
    ORDER BY $wpdb->posts.post_date DESC
 LIMIT 1
 ";

 $pageposts = $wpdb->get_results($querystr, OBJECT);
 //print_r($pageposts);

How to Insert data into database in wordpress | wordpress

global $wpdb;
 
$wpdb->insert( 'table name', array( 'col name1' => value,'col name2' => value ), 
array('%d','%s' ) );

How to add ul class in menu item in wordpress | wordpress.

<?php wp_nav_menu(array(
   'menu' => 'header',
   'theme_location' => 'primary',
    'items_wrap'      => '<ul id="%1$s" class="nav navbar-nav navbar-right">
%3$s</ul>' ,
  ));
  //dynamic_sidebar('sidebar-3');
  ?>

How to Language change in wordpress | Wordpress.

Fist of all you install plugin      qtranxf_getLanguage



 example:if (qtranxf_getLanguage() == 'hr')

How to show post by category in wordpress | wordpress.

query_posts( array( 'category_name' => 'news', 'posts_per_page' => 3) );

 if (have_posts()) : while (have_posts()) : the_post();

 the_permalink();

the_time('d M');

if ( has_post_thumbnail() )
{


 the_post_thumbnail('full');



 }


echo the_title();



echo substr(get_the_content(), 0,250)


 endwhile; endif; wp_reset_query();

How to show post page content using id in wordpress | Wordpress.


query_posts(array('post_type' => 'page','order' => 'ASC', 'post__in' => array(216,220,218,222))); while (have_posts()) : the_post();

the_post_thumbnail_url();

echo the_title();

echo substr(strip_tags(get_the_content()),0,90);

How to show Featured Image in wordpress | wordpress.

There are two functions in WordPress to get post’s featured image.

the_post_thumbnail() – It will display featured image.

get_the_post_thumbnail() – It will return a string containing the HTML code of the featured image.

Complete form validation in js.

Whether api show result according city using js.

The jQuery Example

Jaipur

  • No significant clouds
  • Temperature: 34 °C
  • Wind: Southwest ,
  • Pressure:
  • Rel. Humidity:
  • Visibility:
Reported on:

How to remove public and index.php from URL in laravel | laravel.

1.) First copy all files of public folder and paste in root directry.

2.) open the index file

set path on line no. 21 require __DIR__.'/bootstrap/autoload.php';
and line no. 35   $app = require_once __DIR__.'/bootstrap/app.php';
 
3.) Open .htaccess file and paste following code.

Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

file upload in laravel | laravel.

Use this code in your controller :-

$fileName = Input::file('file')->getClientOriginalName();

$destinationPath = base_path().'/public/upload/';

Input::file('file')->move($destinationPath, $fileName);

How to show validation error messages in view page in laravel

 Following code paste ( after or before) on  you form field where you want show message :-

 @if ($errors->has('fieldname')) <p class="">{{ $errors->first('fieldname') }} @endif

how to get all validation error message together in laravel | laravel.

<span>
@foreach($errors->all(':message') as $message)
{{ $message }}
@endforeach
</span>

how to encode password for insert in db in laravel | laravel.

Hash::make(Input::get('password'));

get all information of online user in laravel | laravel

{{Auth::user()->user_id}},

{{Auth::user()->user_name}}