How to use CSS selector in CSS

agyanadda
<!--DOCTYPE html--> <html> <head> <title>Interal CSS</title> <style> p{ color:red; } #abc{ color:blue; } .ab{ color:green; } </style> </head> <body> <p>Hello How r u[Tag based calling]</p> <p id="abc">Hello[ Id based call]</p> <p class="ab" [Class based call]>My Name is Mohan</p> </body> </html>

How to use web Font in CSS

agyanadda
<!--DOCTYPE html--> <html> <head> <style> @font-face{ font-family:Aclonica; src: url(Aclonica.ttf); } @font-face{ font-family:Acme-Regular; src: url(Acme-Regular.ttf); } h1{ font-family:Aclonica; } h2{ font-family:Acme-Regular; } </style> </head> <body> <h1>AclonicThe @font-face Rule</h1> <h2>AclonicThe @font-face Rule</h2> </body> </html>

How to create auto focus in JavaScript validation

agyanadda
<!--DOCTYPE html--> <html> <head> <title></title> <script> function validatee(){ // 1st Method if(document.forms['frm']['nm'].value == ""){ alert( "Please provide your name!" ); document.forms['frm']['nm'].focus() ; return false; } // 2nd Method /* nmm=document.forms['frm']['nm']; if(nmm.value== ""){ alert( "Please provide your name!" ); nmm.focus(); return false; } */ if (num=document.forms['frm']['noss'].value==""){ document.getElementById("numl").innerHTML="Fill this field"; return false; }else{ return true; } // Number Validation /*var num=document.forms['frm']['noss'].value; //document.getElementById("nameloc").innerHTML=" <img src='checked.gif'/>"; if (isNaN(num)){ document.getElementById("numl").innerHTML="Enter Numeric value only"; return false; }else{ return true; } */ } </script> </head> <body> <div class="fcss"> <form name="frm" onsubmit="return validatee()"> <table border="1"> <tr> <td><input type="text" name="nm" placeholder="Name"></td> </tr> <tr> <td><input type="text" name="noss" placeholder="Mobile"><span id="numl"></span></td> </tr> <tr> <td><input type="submit"></td> </tr> </table> </form> </div> </body> </html>

How to create Calculator by using Javascript

agyanadda

How to create Calculator by using JavaScript. It is so simple only you must have to know the little bit of DOM( Document Object Modal).

<html> <title>Agyanadda cal</title> <style>input[type="button"]{width:100%}</style> <head> <body> <form name="cal"> <table border="1" align="center"> <tr> <td colspan="4"> <input type="text" name="display" id="display" disabled> </td> </tr> <tr> <td><input type="button" name="one" value="1" onclick="cal.display.value += '1'"></td> <td><input type="button" name="two" value="2" onclick="cal.display.value += '2'"></td> <td><input type="button" name="three" value="3" onclick="cal.display.value += '3'"></td> <td><input type="button" class="o perator" name="plus" value="+" onclick="cal.display.value += '+'"></td> </tr> <tr> <td><input type="button" name="four" value="4" onclick="cal.display.value += '4'"></td> <td><input type="button" name="five" value="5" onclick="cal.display.value += '5'"></td> <td><input type="button" name="six" value="6" onclick="cal.display.value += '6'"></td> <td><input type="button" class="operator" name="minus" value="-" onclick="cal.display.value += '-'"></td> </tr> <tr> <td><input type="button" name="seven" value="7" onclick="cal.display.value += '7'"></td> <td><input type="button" name="eight" value="8" onclick="cal.display.value += '8'"></td> <td><input type="button" name="nine" value="9" onclick="cal.display.value += '9'"></td> <td><input type="button" class="operator" name="times" value="x" onclick="cal.display.value += '*'"></td> </tr> <tr> <td><input type="button" id="clear" name="clear" value="c" onclick="cal.display.value = ''"></td> <td><input type="button" name="zero" value="0" onclick="cal.display.value += '0'"></td> <td><input type="button" name="doit" value="=" onclick="cal.display.value = eval(cal.display.value)"></td> <td><input type="button" class="operator" name="div" value="/" onclick="cal.display.value += '/'"></td> </tr> </table> </form> </body> </head> </html>

How to add,subtract by using function and Switch statement in Javascript

agyanadda

How to create addition, subtraction by using function and switch statement.

<!--DOCTYPE html--> <html> <head> <title></title> <script> alert("1. Addition "+"\n"+"2.Subtraction"); var n1,n2,res; var ch=parseInt(prompt("select your choice:")); // string (parseInt()=>convert into number) function inp(){ n1=parseInt(prompt("Enter 1st nos:")); n2=parseInt(prompt("Enter 2nd nos:")); } switch(ch){ case 1: inp(); //calling res=n1+n2; alert("ADDITION (N1+N2):"+res); break; case 2: inp(); //calling res=n1-n2; alert("SUBTRACTION (N1-N2):"+res); break; default: alert("Invalid"); } </script> <body> </body> </html>

HOW TO CREATE LINK WHEN OPTION SELECT IN HTML

agyanadda

How to create link in dropdown in HTML.It is so simple to create you can see the given example

<select onchange="javascript:Select(this)"> <option value="home">Home</option> <option value="text">Contact</option> </select> <script type="text/javascript"> function Select(elm) { window.location = elm.value+".php"; } </script>

Language Constructors In PHP

agyanadda


Language Constructors in PHP



There is huge collection of in build Language constructor in PHP. That helps us to call 
directly by PHP files.

 Like echo() is not a function. It is Language constructor.

We can use it by using 

echo “PHP”; or echo (“PHP);

Example:  
  • include
  • require  
  • case 
  • if, else if 
  • die()
  • new
  • return etc



Escaping From HTML IN PHP

agyanadda

Escaping From HTML:

Everything outside of a pair of opening and closing tags  ore Elements is ignored by the PHP parser. It allows PHP files to have mixed content. 
It allows PHP to be embedded in HTML documents.
Following are the some example of PHP

Example 1:
  <p>Ignored by PHP and displayed on browser.</p>
  <?php echo 'Hello display PHP '?>
  <p>Ignored by PHP and displayed on browser.</p>


Example 2:

<?php if ($expression == true): ?>
  This will show if the expression is true.
<?php else: ?>
  Otherwise this will show Hello PHP.
<?php endif; ?>

Example 3:

<?php for ($i 0$i 10; ++$i): ?>
Hello, PHP!
<?php endfor; ?>


How to insert records in Laravel using database

agyanadda

Add records in DB in laravel

1.     Create model: php artisan make:model employe –m
Model created:  name: employe [ apps/provider ]  

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class employe extends Model
{
    //
}

2 . Created migration: name [ 2018_03_21_045529_create_employes_table]
public function up()
    {
        Schema::create('employes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('mobile');
            $table->string('address');
            $table->timestamps();
        });
    }

3. Execute command :  php artisan migrate;
Note: if there is error while migrate then follow given following steps;
GO  TO: App\providers and open it=  [ AppServiceprovider.php] and add given code
  use Illuminate\Support\Facades\Schema;     // add it
  public function boot()
    {
        Schema::defaultStringLength(191);     // add it
    }
Now, execute your command: php artisan migrate;   and  php artisan migrate:refresh;
Now created: controller :  App\http\Controller  [ php artisan make:controller <controller-name>
Example :  php artisan make:conntroller EmployeeController -r
Add: use App\employe; [ where employee = model name]
  
 public function create()
    {
        $emp = new employe;
        $emp->name='Aryan';
        $emp->mobile='78585';
        $emp->address='Delhi';
        $emp->save();  // by default save() method
    }


Now: Got to Route folder: [web.php]
 Route::get('/save', 'EmployeeController@create');


Route::get(‘/localhost url [name],’Controller name @ method name’)



                                   

Save Record from textbox;
Create : registration.blade.ph


Laravel First Program

agyanadda

How to create Modal . controller and index page in Laravel

================================================= Model= college.php ================================================= <!--php namespace App; use Illuminate\Database\Eloquent\Model; class College extends Model { public $name='SMSG COLLEGE'; public $pin=824211; } ================================================== Controller= CollegeController.php ================================================== namespace App\Http\Controllers; use Illuminate\Http\Request; use App\College; class CollegeController extends Controller { public function index(){ $collg= new College(); $nm = $collg--->name; $pn = $collg->pin; return view('College.index',compact('nm','pn')); } } ===================================================== Views= index.blade.php ===================================================== <!--DOCTYPE html--> <html> <head> <title>LaravelAPP</title> </head> <body> Welcome to laravel <br> {{$nm}} {{$pn}} </body> </html> ====================================================== Routes= web.php ====================================================== Auth::routes(); Route:: get('/index','CollegeController@index');

Mysql All join-create-table-foreign-key-primary-key

agyanadda

In This post we will discuss:

  1. How to connect mysql using command prompt (CMD)
  2. Show Databases
  3. How to select database
  4. How to Create tables
  5. How to show structure of table
  6. How to insert multiple Records at a time
  7. How to Create to create auto_increment and primary key
  8. How to Create to create Foreign Key
  9. How to Create to create inner join
  10. How to Create to create Leftjoin
  11. How to Create to create right join
Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. ============[ connect mysql using command prompt ]================== C:\Users\Nandan>cd C:\xampp\mysql\bin C:\xampp\mysql\bin>mysql -u root -p1234; ===================================================================== Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 10.1.22-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. =====================[Show database ] =============================== MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | shoppingdb | | test | +--------------------+ 17 rows in set (0.00 sec) =======================[ Change dasebase ]=========================== MariaDB [(none)]> use test; Database changed ============================[ Show Tables ]=========================== MariaDB [test]> show tables; +----------------+ | Tables_in_test | +----------------+ | abc1 | | abc2 | +----------------+ 4 rows in set (0.00 sec) =========================[ Create table ]============================= MariaDB [test]> create table empinfo( -> id int auto_increment primary key, -> eid int not null, -> salary int, -> address varchar(100), -> foreign key(eid) references emp(id) -> ); Query OK, 0 rows affected (0.21 sec) ==============[ Create emp Table ]=============================== MariaDB [test]> create table emp( -> id int auto_increment primary key, -> name varchar(30), -> mobile varchar(12), -> branch varchar(100) -> ); Query OK, 0 rows affected (0.21 sec) ==============[ Show Tables ]================================ MariaDB [test]> show tables; +----------------+ | Tables_in_test | +----------------+ | abc1 | | abc2 | | emp | | empinfo | +----------------+ 4 rows in set (0.00 sec) ==============[ Show structure of Tables ]=================== MariaDB [test]> desc emp; +--------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(30) | YES | | NULL | | | mobile | varchar(12) | YES | | NULL | | | branch | varchar(100) | YES | | NULL | | +--------+--------------+------+-----+---------+----------------+ 4 rows in set (0.04 sec) ==============[ Create empinfo primary key Table ]=============== MariaDB [test]> create table empinfo( -> id int auto_increment primary key, -> eid int not null, -> salary int, -> address varchar(100), -> foreign key(eid) references emp(id) -> ); Query OK, 0 rows affected (0.21 sec) ==============[ Show structure of Tables ]=================== MariaDB [test]> desc empinfo; +---------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | eid | int(11) | NO | MUL | NULL | | | salary | int(11) | YES | | NULL | | | address | varchar(100) | YES | | NULL | | +---------+--------------+------+-----+---------+----------------+ 4 rows in set (0.04 sec) ==============[ Create Multiple Records in Tables ]=================== MariaDB [test]> insert into emp(name,mobile,branch)values("Mohan","90938392","MC A"),("Geeta","928282822","BCA"),("Rakhi","8735362222","Btech"); Query OK, 3 rows affected (0.06 sec) Records: 3 Duplicates: 0 Warnings: 0 MariaDB [test]> select *from emp; +-----+-------+------------+--------+ | id | name | mobile | branch | +-----+-------+------------+--------+ | 101 | Mohan | 90938392 | MCA | | 102 | Geeta | 928282822 | BCA | | 103 | Rakhi | 8735362222 | Btech | +-----+-------+------------+--------+ 3 rows in set (0.00 sec) MariaDB [test]> select *from empinfo; +----+-----+--------+---------+ | id | eid | salary | address | +----+-----+--------+---------+ | 13 | 101 | 4000 | Noida | | 15 | 103 | 9000 | Delhi | +----+-----+--------+---------+ 2 rows in set (0.00 sec) =================================[ Inner Join of Tables ]=================== MariaDB [test]> select emp.id,emp.name,empinfo.salary from emp inner join empinf o on emp.id=empinfo.eid; +-----+-------+--------+ | id | name | salary | +-----+-------+--------+ | 101 | Mohan | 4000 | | 103 | Rakhi | 9000 | +-----+-------+--------+ 2 rows in set (0.00 sec) ===================================[ Left Join of Tables ]=================== MariaDB [test]> select emp.id,emp.name,empinfo.salary from emp left join empinfo on emp.id=empinfo.eid; +-----+-------+--------+ | id | name | salary | +-----+-------+--------+ | 101 | Mohan | 4000 | | 103 | Rakhi | 9000 | | 102 | Geeta | NULL | +-----+-------+--------+ 3 rows in set (0.00 sec) ===================================[ right Join of Tables ]=================== MariaDB [test]> select emp.id,emp.name,empinfo.salary from emp right join empinf o on emp.id=empinfo.eid; +------+-------+--------+ | id | name | salary | +------+-------+--------+ | 101 | Mohan | 4000 | | 103 | Rakhi | 9000 | +------+-------+--------+ 2 rows in set (0.00 sec)

Click button copy to clipboard using jQuery

agyanadda
<!--DOCTYPE html--> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> function copyToClipboard(element) { var $temp = $("<input>"); $("body").append($temp); $temp.val($(element).text()).select(); document.execCommand("copy"); $temp.remove(); } </script> </head> <body> <br><br> <pre id="copyy">Thanku for copy me </pre> <button onclick="copyToClipboard('#copyy')">Click to copy ME</button> <br/><br/><input type="text" placeholder="Paste here for test" /> </body> </html>