Printer Friendly Version Of Your Web Page Content

Some times we need to put an option in our web page so that user can take a print of the content of the page like ‘Click here to Print’ button.
For printing the content we can use JavaScript so that user can print the content of the page only and the other graphics, page layout will be ignored at the time of printing.

Here is the code snippet.

Everything is done. Now any one can get a print out of the content of your web page.

Continue Reading

How to Create Simple WordPress Breadcrumbs?

Breadcrumbs is a navigation aid used in user interfaces. It gives users a way to keep track of their locations within programs or documents. Breadcrumbs typically appear horizontally across the top of a web page, usually below title bars or headers. They provide links back to each previous page the user navigated through to get to the current page or—in hierarchical site structures—the parent pages of the current one.

You can use Breadcrumbs feature in your WordPress post page or content page to show the hierarchy.

Home » Parent Page » Sub Page1 » Sub Page2
Home » Category » Subcategory » Post Name

Step 1: In your function.php file put the following code for Breadcrumbs.

Step 2: In the header.php or in your theme page put the following code to display the Breadcrumbs.

<?php if (function_exists('wordpress_breadcrumbs')) wordpress_breadcrumbs(); ?>

Step 3: All that remains to do for now, is to design your breadcrumbs with CSS. You can use #crumbs for styling breadcrumbs block and #crumbs .current for styling a current crumb.

Continue Reading

How to set password to your root user in XAMPP

By default XAMPP has no password to it’s ‘root’ user but we can set password for this user by the following steps:

1. Open phpmyadmin
2. Click on SQL tab
3. Copy & paste the following query:

UPDATE mysql.user SET Password=PASSWORD('password') WHERE
 User='root';
 FLUSH PRIVILEGES;

4. Refresh the page & will get an error message

Modifying phpMyAdmin config file:
1. open xampp installation path / phpmyadmin / config.inc.php
2. Search for the string $cfg[‘Servers’][$i][‘password’] = ”;
3. it will be like: $cfg[‘Servers’][$i][‘password’] = ‘password’;
Here the ‘password’ is what we set to the ‘root’ user using the SQL
query.
4. Chnage the line:
$cfg[‘Servers’][$i][‘auth_type’] = ‘config’;
to
$cfg[‘Servers’][$i][‘auth_type’] = ‘http’;
5. Now all set to go. Save the config.inc.php file and restart the XAMPP server.

Continue Reading

Style your web form with CSS

We have to use different forms in our website for different purposes like login form, registration form and so on. Web form plays a great role for the user point of view. Simple form attracts the users more to fill up. We can design a simple User Registration form with CSS in a proper manner as like as the image below.

Continue Reading

Download file script in PHP

Some times we  need to create a download link of any file in our site. We can point a direct link of the file to download but in this case we can get the absolute path of that file which is not preferred to us. Moreover some browsers redirect the download link path in a new window.

Hence we can create a separate PHP script through which we can download any file and there will be no possibility to access the absolute path of the file and no redirection to the other page. We can get the save file pop window in the same window.
Step 1: Create a PHP file named download.php and put the following codes in it.

Step 2: Now wherever you want to put the download file link, put the following code:

 <a href="download.php?filename=yourfilename.zip">Click here to Download the File</a>
Continue Reading

Display data horizontally from MySQL table

Generally we fetch data from MySQL table and display the fetch records in rows one by one. But sometimes we need to display the records horizontally as per the image below.

Sir Isaac Newton Leonardo Vinchi William Shakespeare
Adolf Hitler Siddhartha Gautama Ian McKellen
Abraham Jesus of Nazareth Walt Disney

It’s not a tough job. You can see that the records are pulling up and displaying 2 records in a row and after that in the next rows for the next 2 records. The code for such display style is as follows:

Continue Reading

How to generate thumbnails image on the fly with PHP

Thumbnail-Genertion-Banner

Many a time we need to create thumbnails of the uploaded images on the fly. In PHP we can create thumbnail at the time of uploading image.

The PHP functions you need to know about for this script.

Steps to generate thumbnails.

  1. Make a folder named ‘images’ inside your web directory.
  2. Make a sub folder named ‘thumbs’ inside‘images’ folder’.
  3. Create a PHP page for example‘thumbnail.php’ inside your root folder.
  4. Now place the following codes in‘thumbnail.php’.
    It’s done. Now run the thumbnail.php file through your browser http://yourdomain.com/thumbnail.php
Continue Reading