Create A Very Advanced Image Gallery With Only Few Lines Of Codes With PHP, HTML, CSS

You want to create a Web image gallery and don’t want to write repetitive code? then here is simple script, place it in a directory and also images in same directory under a folder called “images” and that’t it. It will list and display images itself. Not only that, it names the images from the file name, all you to do is rename images to the requirement.

Image gallery script

Here is the code

Continue reading Create A Very Advanced Image Gallery With Only Few Lines Of Codes With PHP, HTML, CSS

Create your own WordPress theme from scratch [Part 3]

In last part we have coded index.php and header.php,  here we will code content.php, this page will display the posts and search results, and posts under categories, pages , etc.

here is the code for content.php

The above code looks to0 complicated, let me break it for you line by line. Continue reading Create your own WordPress theme from scratch [Part 3]

Access files from computer on android devices over WiFi

Your device may not have enough storage space to hold all your files you need, or maybe you just like to stream movies or music stored on your computer to your phone, or you can just see your documents you just updated on your computer in your android device. Then here is how you can do it, what you will need is a computer connected to LAN network and android device connected to same network over WiFi.

Download and install this File manager app from Google Play store on your android device.

And now check your computer”s IP, read HOW TO KNOW YOUR COMPUTER IP?[WINDOWS]

Now as you know your computer IP, note it down.

Now, open your Control Panel and Continue reading Access files from computer on android devices over WiFi

Create your own WordPress theme from scratch [Part 2]

Here is a basic theme idea, how the things are gonna be arranged in the theme.

basic wordpress theme layout

First, create a empty folder in wordpress’s main directory -> wp-content -> themes, name the new folder as testtheme.

Now create a new css style sheet named style.css and add the below code to it and save it to empty folder of theme.

That css page adds the description and info about theme to wordpress dashboard, that code basically works as theme description. Now, you can see that your new theme is available to be activated from dashboard. Don’t activate it yet, as there no other files in the folder except for the style.css page. Continue reading Create your own WordPress theme from scratch [Part 2]

Emulate and test your website on different devices virtually.

It is almost impossible to test your website for compatibility on all different devices, especially when you don’t have much time. Hence, it will ease your work when you have a tool to emulate the device and check it at different compatibility. It is possible with Google Chrome Canary, it has special feature for developers which enables to emulate few different devices. You can also emulate a custom device. So, it should be nothing but good gift for web designers.

Here is how to do it.

1) First download and install Chrome Canary from here.

https://www.google.co.in/intl/en/chrome/browser/canary.html

2) After you have installed it. Open the site you want to check compatibility for. ( I open google.com) Continue reading Emulate and test your website on different devices virtually.

Create your own WordPress theme from scratch [Part 1]

Here is how to code your WordPress theme from scratch. If you have a HTML/CSS template ready and you want to turn it into fully functioning theme then you are at right place. You don’t need to be a very intelligent coder or a software engineer to code your own theme, all you need is little bit of time, patience and a bit of knowledge( which can be gained by just surfing for a few hours.).

Who is this tutorials for :

  • Those want to create a theme by themselves for WordPress.
  • Those who have basic knowledge of HTML, CSS and PHP.
  • Those who need help in coding.

Who isn’t it for:

  • Professional coders who is already knowing a lot about this and expecting better stuff here.
  • Those who wants to code a next-gen theme which is fully loaded, because this tutorials is for basic learners and only low level stuffs are taught here.

So lets get started…

Here is what are we gonna require first to get started.

  • Basic Template
  • CSS Styling

and we’re going to convert theme into theme.

 But….

As you know WordPress theme doesn’t have to be a single page code. We can break the main page into parts like.

  • Index.php . This page is the index page where we will include all the other blocks.
  • Sidebar.php This sidebar page, this will hold all the widgets and everything we want to include in side.
  • Header.php This is common page for all, it will handle all the heading, page linking, script linking and many things.
  • Footer.php this is also common, it will hold everything that you want to include at the bottom of page.
  • Content.php This is the page which will print the lists posts for the index.php
  • Single.php this is the page which will open when you click to open a single article.
  • Comments.php , this page will show the comments.
  • Search.php This is the page which will show the search results.
  • searchform.php this the page which holds your custom search for( it is not really necessary as there is already a built in search form).
  • Tags.php this will show the lists of posts tagged under same tags.

So, understand them. Now we must break our custom theme into parts and start coding.

NEXT PART:
CREATE YOUR OWN WORDPRESS THEME FROM SCRATCH [PART 2]

Android apps you may not be knowing even existed [Part-1].

Here few apps I find useful and very helpful in certain situations. I hope they are of some use to you too.

QuickPic

Are you bored of you stock gallery? then probably you should get an alternate to it.

https://play.google.com/store/apps/details?id=com.alensw.PicFolder&hl=en

It has many inbuilt functions which aren’t available in the default gallery, this is what it makes a must have gallery app.

App Backup and Restore

This is another great app, if you want to switch the phone or temporarily remove any app then you will find this app of great use, you can back up your files in apk format and install it any other devices. Perhaps, you can also backup the apks and preserve them on your computer.

https://play.google.com/store/apps/details?id=mobi.infolife.appbackup&hl=en

Truecaller

Truecaller is an app that is great for everybody, It is just like an universal phone directory. It has a huge database of contacts from many different countries. So, you will always get the name before pickup the phone, even the unknown country. Got to try this by yourselves.

https://play.google.com/store/apps/details?id=com.truecaller&hl=en

Fake-A-Call

This is totally a fun app, you can set the calls to ring yourself like an alarm. Caught up in useless talks? want to get out from there? then ring yourself. This is just a great app to fool people.

https://play.google.com/store/apps/details?id=net.excelltech.fakeacallfree2&hl=en

Music Off- Music Timer

Do you like to listen to music while you are in bed? then this is best tools for you, it turns off the music as soon as you fall asleep, automatically. It is really a smart app. Try it.

https://play.google.com/store/apps/details?id=asia.utopia.musicoff&hl=en

[How to] Store and Display images from MySQL using PHP

Now everything is database driven and people are willing to involve the db technology everywhere. So, lets see what we can do to throw a image on the screen not directly from the directory, where it is stored as it is. But, we will see how we can store the image in DB and display images from db.

As we are going to do it, I want to tell you what are the procedures involved in it.

First, we will read the images in the binary mode(Binary mode because it can represent anything) using a PHP script, and all the binary code will be stored in the database as is.

Next, we will give the name or number to those data for the identification.

And at last, we will create a script which will access the db, read the data into it, and display image.

Sounds simple isn’t it? Here create a table named imagedb

Now lets create a page called ” store.php ” because it the page we will use to read the images, and store it in DB.

The code we will add to it are

Save the file, and now create a new file called “images.php” and add this code below. this is the page which will fetch us image from the DB.

$data = $sth->fetchAll();
echo $data;

Now type the url http://localhost/path/to/image.php?id=id_u_used , tadaaa, you can see the image.

if you want to put your images somewhere, just use

<img src=”image.php?id=image_id” />

Generate a simple line graph with Pure PHP

You might want to generate a dynamic line graph to show some statistics, you don’t want to involve yourself into lot of tricky programming? Then let’s just use the PHP GD and Image Functions to do it.

Open a PHP page and add this code:

[php]

header(“Content-Type: image/png”); //this will set header as png image

$im = @imagecreate(800 , 600) //this is size of the canvas

or die(“Cannot Initialize new GD image stream”);

$background_color = imagecolorallocate($im,255 ,255 ,255); //background color as white
$black = imagecolorallocate($im, 0, 0,0);

imageline($im, 80 ,480,650,480, $black); //this for x-axis
imageline($im, 100,40,100,500, $black); //this for y-axis

//division on x-axis
$x_add = 50;
for($i = 0; $i <= 9 ; $i++){
imageline($im, 150+($i*$x_add), 480, 150+($i*$x_add) , 500, $black);
}

//division on y-axis
$y_add = 40;
for($i = 0; $i <= 10 ; $i++){
imageline($im, 80, 480-($i*$y_add), 100 , 480-($i*$y_add), $black);
}

$names_on_x_axis = array(1,2,3,4,5,6,7,8,9,10); // here is where you put the names for values on x-axis
$values_on_x_axis = array(1,2,30,4,5,50,7,8,9,10 ); //put the corresponding value
$y_axis_initial = 1; // here is where you put initial value for y-axis
$y_axis_interval = 10; // here is where you put needed interval value for y-axis

//write values on x – axis,
for($i = 0; $i <= 9 ; $i++){
imagettftext($im, 12,270, 148+($i*$x_add) , 508, $black, ‘font.otf’,$names_on_x_axis[$i] );
}

//write values on y-axis
for($i = 1; $i <= 10 ; $i++){
imagettftext($im, 12,0, 50 , 485-($i*$y_add), $black, ‘font.otf’,$y_axis_initial + (($i*$y_axis_interval)-1) );
}

//calculation part
$total_height = $y_add * 10; //height of graph

//this function will calculate the height for the points
function needed_height($input_value){
global $total_height, $y_add , $y_axis_interval ;
return 480-(($input_value/$y_axis_interval)*$y_add);}

//now to draw line graph
for($v = 2 ;$v<=10 ; $v++)
imageline($im,148+(($v-2)*$x_add),(needed_height($values_on_x_axis[$v-2])),148+((($v-2)+1)*$x_add),(needed_height($values_on_x_axis[$v-1])),$black);

imagepng($im);
imagedestroy($im);

[/php]

and save this page.

You can change values and names for the values by changing the values in arrays named “$names_on_x_axis” and “$values_on_x_axis“,

to change y-axis interval and values edit “$y_axis_initial” “$y_axis_interval“.