How to use alternate row color in a html table

Js

Posted on 13 May 15 by Vickey
  1275

For showing each row different we can use alternate row color in a table. For give different color we need to add a differnt style or different backgrownd color here is a way to give different background color to alternate rows In this example i have a table with id "diffcolor".

<table style="width:100%" id="diffcolor">
  <tr>
    <td>Jack</td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
  <tr>
    <td>Paul</td>
    <td>Jackson</td> 
    <td>94</td>
  </tr>
    <tr>
    <td>Alen</td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
      <tr>
    <td>Jill</td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
        <tr>
    <td>Bob</td>
    <td>Joy</td> 
    <td>50</td>
  </tr>
</table> 

here is js function for add different background color to the alternate rows

function tableRowColor(id){
  if(document.getElementsByTagName){
    var table = document.getElementById(id);
    var rows = table.getElementsByTagName("tr");
    for(i = 0; i < rows.length; i++){
      if(i % 2 == 0){
        rows[i].className = "even";
      }else{
        rows[i].className = "odd";
      }
    }
  }
}

and now we need to call this function and pass table id

tableRowColor('diffcolor');

this function will add different class on table's rows now we need to give style

   .even{
    background: #f2f2f2;
   }
   .odd{
    background: #fff;
   }

How to change defualt login redirect in laravel5

Laravel

Posted on 07 May 15 by Vickey
  611

when you login with the defualt login of laravel5 it will redirect to /home but if you want to change this follow these steps

Go to directory

laravel5/vendor/laravel/framework/src/Illuminate/Foundation/Auth

Open file AuthenticatesAndRegistersUsers.php and search this

public function redirectPath()
{
    if (property_exists($this, 'redirectPath'))
    {
        return $this->redirectPath;
    }

    return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home';
}

here you can change your custom path like this

public function redirectPath()
{
    if (property_exists($this, 'redirectPath'))
    {
        return $this->redirectPath;
    }

    return property_exists($this, 'redirectTo') ? $this->redirectTo : '/dashboard';
}

What is interface in php

Object Oriented Programming

Posted on 06 May 15 by Vickey
  543

Interface is a class or we can say base class which is implement in a child calss. We defined interface by using keyword interface. all method or function of a interface should be public according the nature of interface.Function in interface does not have any functionality these are overwride in child class and these are necessary to use child class

interface setTemplate
{
    public function setVar($var);
    public function getVar($var);
}

class template implements setTemplate{

    fuction setVar($var){

        function body.......

    }

    fuction getVar($var){

        function body.......

    }
}

if we does not use all function of a interface then it will give erorr

class template implements setTemplate{

    fuction setVar($var){

        function body.......

    }
}

the above code will return error

like abstract class we can create object of a interface we only implement it in a child class

Abstract class in php

Object Oriented Programming

Posted on 02 May 15 by Vickey
  556

As you know the meaning of abstract is hidden or unvisiable yes the role of abstract classes are same. abstract class can not initialized directoly or we can say that we can not create object of abstract classes. we always use abstract class as a base class and inherit in a child class. In abstract class at least one function should be abstract. we can in inherit an abstract calss in another abstract class we can create abstract class by adding abstract keyword before class keyword.

abstract class mybaseclass(){

    abstract protected function sum($a,$b){

    }
}

we can declare abstract function in child class

class mychildclass extends mybaseclass(){

        protected function sum($a,$b){
          $sum=$a+$b;
      echo $sum;
       }
}

 

How to set cronjob with putty or terminal

Ubuntu Desktop

Posted on 21 Apr 15 by Vickey
  1303

Open your putty or terminal and login via ssh

you will see like this

[root@ip-11-142-86-04 ~]# 

Now run command

[root@ip-11-142-86-04 ~]# crontab -e

this will show the list of cronjobs if already set but you can not edit these. for edit press insert button now you can edit or add new cron job. for example if you want to add new one you will write

*/1   *     *     *    *   curl http://domain.com/php_script.php

at the place of stars you will put cronjob time

MIN HOUR MDAY MON DOW COMMAND

*/1 * * * * curl http://domain.com/php_script.php

MIN - Minute 0-60

HOUR - Hour [24-hour clock] 0-23

MDAY - Day of Month 1-31

MON - Month 1-12 OR jan,feb,mar,apr...

DOW - Day Of Week 0-6 OR sun,mon,tue,wed,thu,fri,sat

COMMAND - command-line

when you have done, press Esc key and you will be exit from edit mode

now type :wq and press enter you will exit from cronjob window

How to login with opensshkey on ubuntu terminal

Ubuntu Desktop

Posted on 21 Apr 15 by Vickey
  533

Locate to dirctory in which ppk file exist

cd /home

and run the below command

puttygen web.ppk -O private-openssh -o my-openssh-keyD

now you can see my-openssh-key file in your directory. again run a command

sudo ssh -v root@123.456.8.99 -i my-openssh-key

now you will login with ssh key

How to add new column in databse table by laravel Migrate

Laravel

Posted on 21 Apr 15 by Vickey
  595

For add new column by migrate run this command

php artisan migrate:make add_status_to_users

in Laravel 5 use

php artisan make:migration add_status_to_users

now go in your migrate directory you will see new migrate file with this name open

Schema::table('users', function($table){

    $table->integer('status');

}

you can add more column

Schema::table('users', function($table){

    $table->integer('status');
    $table->integer('role_id');

}

save this file and run

php artisan migrate

How to install xampp on ubuntu desktop

Ubuntu Desktop

Posted on 20 Apr 15 by Vickey
  577

If we want to install lampp on ubuntu server then we need to run different commands for mysql phpmyadmin, php apache but we can install all these things from a single package name as xampp installer so let install xampp by these steps

  1. First download xampp-linux-x64-5.6.3-0-installer.run from this url

https://www.apachefriends.org/index.html

  1. Save this in your home folder

  2. Give 755 permission to this file

    sudo chmod 755 xampp-linux-x64-5.6.3-0-installer.run

  3. Now install this by this command

    sudo ./xampp-linux-x64-5.6.3-0-installer.run

you will see a popup click on next button and continue

once you have completed process you can start it by command

/opt/lampp/lampp start

How to start xampp server on ubuntu

Ubuntu Desktop

Posted on 19 Apr 15 by Vickey
  449

If you have installed xampp server on ubuntu then when you start your system you will need to start xampp server every time. by this command you can start your xampp server

ubuntu@vickey-HP-2000-Notebook-PC:~$ sudo /opt/lampp/lampp start

For stop server

ubuntu@vickey-HP-2000-Notebook-PC:~$ sudo /opt/lampp/lampp stop

For restart server

ubuntu@vickey-HP-2000-Notebook-PC:~$ sudo /opt/lampp/lampp restart

 

Copy file from server to local and local system to server on ubuntu by command

Ubuntu Desktop

Posted on 19 Apr 15 by Vickey
  601

By command we can copy file from server to local and from local to server. here i am using ubuntu terminal for copy files

1 Copy from server to local

ubuntu@ubuntu-HP-2000-Notebook-PC:~$ scp root@192.168.10.00:/var/www/html/demo.zip.tmp /var/www

in this command first i give file location on server and then directory path of local system where i want to download file

2. Copy files from local to server

ubuntu@ubuntu-HP-2000-Notebook-PC:/var/www$ scp demo.zip.tmp root@192.168.10.00:/var/www/html

www.000webhost.com