Skip to main content

Posts

Showing posts from February, 2018

What is the difference between Jquery Append and Prepend?

Prepend: adds text at the beginning. Append:  adds text at the end. <!DOCTYPE html > < html > < head > < script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" ></ script > < script > $ ( document ). ready ( function (){ $ ( "#btn1" ).click( function (){ $ ( "p" ). prepend ( "<b>Prepended text</b>. " ); }); $ ( "#btn2" ).click( function (){ $ ( "div" ). append ( "<b>Appended text</b>" ); }); }); </ script > </ head > < body > < p > This is a paragraph. </ p > < div > This is another paragraph. </ div > < button id= "btn1" > Prepend Text </ button > < button id= "btn2" > Append Text </ button > </ body > </ html &

Previewing the CSV file being uploaded to database using PHP

< html >   < style > table , th , td { border : 1 px solid black ; border-collapse : collapse ; } </ style > < body > < form method= "post" enctype= "multipart/form-data" > Upload a CSV File:- < input type= "file" value= "Upload CSV Format" name= "csvfile" required /> < input type= "submit" value= "Upload" name= "submit" /> </ form > </ body > </ html > <?php   error_reporting ( 1 );   $server = "localhost" ;   $user_name = "root" ;   $password = "root" ;   $database = "sample" ;   $connection = mysqli_connect ( " $server " , " $user_name " , " $password " , " $database " ) or die ( "Error " . mysqli_error ( $connection ));   $csvfile = $_FILES [ 'csvfile' ][ 'name' ];   $ext = pathinfo ( $c

What is the difference between visibility:hidden and display:none in CSS?

visibility:hidden        -will only hide the content,css but not the space covered by the element. display:none       -will hide both the content,css and space covered by that element. Example: < html > < head > < style > #id2     { visibility : hidden ; } . class2     { display : none ; } #id1 , #id2 , #id3     { background : #ea6645 ; } . class1 ,. class2 ,. class3     { background : green ; } </ style > </ head > < body > < div id= 'id1' > First div with attribute ID1 </ div > < div id= 'id2' > Second div with attribute ID2 </ div > < div id= 'id3' > Third div with attribute ID3 </ div > < div class= 'class1' > First div with attribute class1 </ div > < div class= 'class2' > Second

UPLOAD A CSV FILE TO DATABASE USING PHP

<?php   error_reporting ( 1 );   $server = "localhost" ; $user_name = "****" ;//database username   $password = "****" ;//database password   $database = "sample" ;//database name   $connection = mysqli_connect ( " $server " , " $user_name " , " $password " , " $database " ) or die ( "Error " . mysqli_error ( $connection ));   $csvfile = $_FILES [ 'csvfile' ][ 'name' ];   $ext = pathinfo ( $csvfile , PATHINFO_EXTENSION );   $base_name = pathinfo ( $csvfile , PATHINFO_BASENAME );   if ( isset ( $_POST [ 'submit' ]))   {     if ( $ext == "csv" )    {     if ( is_uploaded_file ( $_FILES [ 'csvfile' ][ 'tmp_name' ]))    {     echo "<h1>" . "File " . $_FILES [ 'csvfile' ][ 'name' ] . " uploaded successfully." . "</h1>" ;    }     $handle = fopen ( $_FILES [ 'cs

Upload video to a folder and store the path to database using php

<?php   if ( isset ( $_FILES [ 'image' ])) {     $errors = array ();     $file_name = $_FILES [ 'image' ][ 'name' ];     $file_tmp = $_FILES [ 'image' ][ 'tmp_name' ];     if ( empty ( $errors )== true )   {     $path = "videos/" . $file_name ;     move_uploaded_file ( $file_tmp , $path );     $server = "localhost" ;     $user_name = "******" ; //database name     $password = "******" ; //database password     $database = "sample" ;     $connection = mysqli_connect ( " $server " , " $user_name " , " $password " , " $database " ) or die ( "Error " . mysqli_error ( $connection ));     $sql = "insert into video(location) values(' $path ')" ; $result = mysqli_query ( $connection , $sql ) or die ( "Error in Selecting " . mysqli_error ( $connection ));     echo "Success" ;    }    

Upload and Retrieve an image from database

/*Create table in sql:*/ CREATE TABLE `images` ( `id` int(11) NOT NULL AUTO_INCREMENT, `image` longblob NOT NULL, `created` datetime NOT NULL, PRIMARY KEY (`id`) ); /*Uploading an image to Database*/ <?php if ( isset ( $_POST [ "submit" ])){ $check = getimagesize ( $_FILES [ "image" ][ "tmp_name" ]); if ( $check !== false ){ $image = $_FILES [ 'image' ][ 'tmp_name' ]; $imgContent = addslashes ( file_get_contents ( $image )); $dbHost = 'localhost' ; $dbUsername = 'root' ; $dbPassword = 'root' ; $dbName = 'sample' ; //Create connection and select DB $db = new mysqli( $dbHost , $dbUsername , $dbPassword , $dbName ); // Check connection if ( $db -> connect_error ){ die ( "Connection failed: " . $db -> connect_error ); } $dateTime = date ( "Y-m-d H:i:s" )