Posts

2021 Top 4 Best Upcoming Flagship Smartphones : which are the best mobile phones for you..?

Image
  Hi here are the top 8 best upcoming flagship smartphones of 2021 with high-end level features improved cameras stunning design and many other next-generation technologies will be applied that you will really enjoy also the price and the release date of the smartphones are discussed. Number four Asus Zenfone 8 Number three OnePlus 9 Number two Huawei P50 Number one Apple iPad Pro 12.9

Import UTF-8 languages from Excel to Database using PHP

Step 1 Reading different languages from excel and dump into database require you to make sure following: 1. Database Charset : UTF-8 2. Table Charset : UTF-8 3. Table Columns Charset : UTF-8 ( columns to store foreign language characters must be set to UTF-8) Step 2 Now we need to read Excel and import it into database, there are many libraries can be use to read excel file using php, I used PHPExcel Now, what we need is to setup database connection $cn = mysql_connect('localhost', 'db_user, 'db_password'); $db = mysql_select_db('TableName'); Now before use mysql_query we need to set following mysql_query("SET NAMES utf8"); mysql_query("SET CHARACTER SET utf8"); Now, use mysql_query to INSERT records into database for UTF-8 characters Sample PHP Code using PHPExcel /** Error reporting */ error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); if (PHP_SAPI == &#

How to make back button with php

Just paste this code if (isset($HTTP_REFERER)) { echo "<a href='$HTTP_REFERER'>BACK</a>"; } else { echo "<a href='javascript:history.back()'>BACK</a>"; }

Joomla - How could we restrict each member to edit, change status of their own article. And also restrict members not to create category?

http://forum.joomla.org/viewtopic.php?f=673&t=749306&p=2889465#p2889465 The ACL rules you are looking for are more refined than what 2.5 offers out-of the box: You have to set "Edit State" to "allow" to grant permission to publish/unpublish, but this permission does not distinguish based upon author. You have to set "Create" to "allow" to grant permission to create articles, but the permission to create includes new subcategories as well. ACL is enforced at the code level, so if one needs additional permissions or finer control of permissions, then this logic needs to be added at the code level. (I don't think you are going to find a solution to your needs through some configuration of permission settings.) The logic you need can be created with just a few lines of code and inserted into select view files - files that can be overridden so the changes are safe from upgrades. Here is an approach tha

MySQL: deleting tables with prefix

You cannot do it with just a single MySQL command, however you can use MySQL to construct the statement for you: In the MySQL shell or through PHPMyAdmin, use the following query SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )     AS statement FROM information_schema.tables     WHERE table_name LIKE 'myprefix_%'; This will generate a DROP statement which you can than copy and execute to drop the tables. EDIT: A disclaimer here - the statement generated above will drop all tables in all databases with that prefix. If you want to limit it to a specific database, modify the query to look like this and replace database_name with your own database_name: SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )     AS statement FROM information_schema.tables     WHERE table_schema = 'database_name' AND table_name LIKE 'myprefix_%';   Thanks to Andre Miller

Move specific records on top of the list beside ORDER BY

Image
Suppose you have all countries name in MySQL db table like: and you want to show some specific countries on top of the list and remaining countries will start after them. So this query can do it. SELECT * FROM countries ORDER BY country_name = 'Australia' desc,          country_name = 'United arab emirates' desc,          country_name = 'Pakistan' desc,          country_name = 'United kingdom' desc,          country_name = 'United states' desc,          country_name asc;

Log out skype on mac

Image
Follow this quick video  or At the bottom of the screen, on the left hand side there are 4 virtual buttons, Back, Home, Recent Apps and Menu. Menu is the one with 4 lines. Tap that and then there is an option to Sign Out.

Unlink file in CodeIgniter

If you try to use unlink in CI as $filestring  =  base_url ( ) . 'uploads/' . $ filename ; unlink  (  $filestring ) ; you will face such error message: A PHP Error was encountered Severity: Warning Message: unlink() [function.unlink]: http does not allow unlinking Filename: controllers/face.php Line Number: 109 because CI does not understand the  path we specified, therefore to remove a file we have to either use: $filestring  =  APPPATH . '../uploads/' . $filename ; unlink ($filestring) ; or   define ( 'PUBPATH' , str_replace ( SELF , '' , FCPATH ));  // in index.php and $filestring  =  PUBPATH . 'uploads/' . $ filename ;    // in controller

jQuery Moving Items from one list to another

Image
$( document ).ready(function() { $('#add').click(function() { return !$('#select1 option:selected').appendTo('#select2'); }); $('#remove').click(function() { return !$('#select2 option:selected').appendTo('#select1'); }); }); <div> Group 1:     <select multiple id="select1">         <option value="1">Ajax</option>         <option value="2">jQuery</option>         <option value="3">JavaScript</option>         <option value="4">Moo Tools</option>         <option value="5">Prototype</option>         <option value="6">Dojo</option>     </select>     <a href="#" id="add">add &gt;&gt;</a> </div> <div> Group 2:     <select multiple id="select2">         <op

Creating SEO friendly URLs with the merger of Wordpress and CodeIgniter

Objective: Suppose you are required to create SEO friendly URLs with the merger of WP and CI, WP as front-end and CI as admin panel. You are adding projects with CI and showing detail of that project with WP. Steps: Code in controller (project.php) // create user friendly url string as per project name $pro_name = “new project name”; $pro_url = strtolower(str_replace(' ','-',trim($pro_name))); // insert in to wp_posts table $post = array( 'post_title' => $pro_name, 'post_name' => $pro_url, 'post_type' => 'page' ); $post_id = $this->utility_model->set('wp_posts', $post); // insert in to wp_postmeta table $postmeta = array( 'post_id' => $post_id, 'meta_key' => '_wp_page_template', 'meta_value' => 'project-detail.php' ); $this->utility_model->set('wp_postmeta', $postmeta); /* insert in to

Check who had read email?

In your email content add this code <img src="http://yourdomain.com/emailreceipt.php?receipt=<receiver_emailid" /> And in emailreceipt.php log it in to a database, although again this is restricted by the email client's ability to show images and sometimes it may even put the mail into junk because it doesn't detect an image... a workaround that would be to actually outputting an image (say your logo) at the end of that script.

How to sum total time utilize in each week of a month?

Image
Assuming that the attendance table has a date column attendance_date , the below query may give you total time utilized per week in the month: SELECT WEEK (` attendance_date `) ` attendance_week `, SEC_TO_TIME ( SUM ( TIME_TO_SEC (` time_utilize `))) ` attendance_time_utilized ` FROM ` attendance ` GROUP BY ` attendance_week `; In the above query, the attendance_week is calculated as the week of the year, between 1 and 52. Another form of output might be to show weeks as 1,2,3,4. For it, you may try this query: SELECT (` attendance_week ` - ` min_week ` + 1 ) ` att_week `, ` attendance_time_utilized `  FROM (  SELECT WEEK (` ATT `.` attendance_date `) ` attendance_week `,  SEC_TO_TIME ( SUM ( TIME_TO_SEC (` ATT `.` time_utilize `))) ` attendance_time_utilized `,   ` T1 `.` min_week `  FROM ` attendance ` ` ATT `   INNER JOIN ( SELECT MIN ( WEEK (` attendance_date `)) ` min_week ` FROM ` attendance `) T1  GROUP BY ` attendance_week ` ) T2 ;    H

Create div using jquery with fade in effect

Image
If you want to get some text from php file and display on a browser using jquery such that each time a new row will add at top of other and with fade in effect: Your script should like

Add Class for Image in Content

The given PHP example adds a class to the standard classes in Images in Posts/Pages in WordPress. <?php function bb_add_image_class($class){ $class .= ' scale-with-grid'; return $class; } add_filter('get_image_tag_class','bb_add_image_class'); ?>

Get URL Thumbnail

The given PHP example get the thumbnail URL in WordPress. <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 140,140 ), false, '' ); echo $src[0]; ?>

Change Login Logo and Login Link

The given PHP example helps you to change the login logo and the login link into WordPress. <?php function custom_loginlogo() { echo ' '; } add_action('login_head', 'custom_loginlogo'); add_filter( 'login_headerurl', 'custom_loginlogo_url' ); function custom_loginlogo_url($url) { return 'http://www.wpbeginner.com'; } ?>

Hide The Front-End Dashboard Bar

The given PHP example helps you to hide the Front-End dashboard bar from WordPress. Place this in your index.php before wp_footer() is called. <?php show_admin_bar( false ); ?>

Get the First Image from the Post and Display it.

The given PHP example allows you to automatically get the first image from the current post, and display it into WordPress. <?php function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/ /i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; } echo catch_that_image(); ?>

Display Post Views Within Admin Post Columns

The given PHP example will display the post views within admin post columns into WordPress. <php add_filter('manage_posts_columns', 'posts_column_views'); add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2); function posts_column_views($defaults){ $defaults['post_views'] = __('Views'); return $defaults; } function posts_custom_column_views($column_name, $id){ if($column_name === 'post_views'){ echo getPostViews(get_the_ID()); } } ?>

Multidimensional Array Sort

The given PHP example order any multidimensional array based on a specific field. <php function orderMultiDimensionalArray ($toOrderArray, $field, $inverse = false) { $position = array(); $newRow = array(); foreach ($toOrderArray as $key => $row) { $position[$key] = $row[$field]; $newRow[$key] = $row; } if ($inverse) { arsort($position); } else { asort($position); } $returnArray = array(); foreach ($position as $key => $pos) { $returnArray[] = $newRow[$key]; } return $returnArray; } ?>

Filter Category

The given PHP example filter out a category from your WordPress. Add this code to your functions.php file. <?php function exclude_cat(){         if(is_home) {                 $query-> set('cat','-312');         }         return $query; } add_filter('pre_get_posts','exclude_cat'); ?>