jquery ক্যোয়ারীর জন্য তারিখ অনুসারে বাছাই করা পোস্ট দেখানো হচ্ছে৷ প্রসঙ্গ অনুসারে বাছাই করুন সব পোস্ট দেখান
jquery ক্যোয়ারীর জন্য তারিখ অনুসারে বাছাই করা পোস্ট দেখানো হচ্ছে৷ প্রসঙ্গ অনুসারে বাছাই করুন সব পোস্ট দেখান

Javascript - validation, numbers only

 jQuery('.decimal').on('keydown', function (event) {return isNumberOveride(event, this);});


function isNumberOveride(evt, element) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if ((charCode != 190 || $(element).val().indexOf('.') != -1) // “.” CHECK DOT, AND ONLY ONE.
&& (charCode != 110 || $(element).val().indexOf('.') != -1) // “.” CHECK DOT, AND ONLY ONE.
&& ((charCode < 48 && charCode != 8)
|| (charCode > 57 && charCode < 96)
|| charCode > 105))
return false;
return true;
}
Read More

Litebox Image Gallery Using PHP

 <?php

include("header.php");

?>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.0/css/lightbox.css">

<style> 

#imgTest:hover{

box-shadow: 0px 0px 10px 2px rgba(0,0,0,1);

}

</style>

      <!-- Breadcromb Area Start -->

      <section class="gauto-breadcromb-area section_70">

         <div class="container">

            <div class="row">

               <div class="col-md-12">

                  <div class="breadcromb-box">

                     <h3>Gallery</h3>

                     <ul>

                        <li><i class="fa fa-home"></i></li>

                        <li><a href="index.php">Home</a></li>

                        <li><i class="fa fa-angle-right"></i></li>

                        <li>Gallery</li>

                     </ul>

                  </div>

               </div>

            </div>

         </div>

      </section>

      <!-- Breadcromb Area End -->





      <!-- About Page Area Start -->

      <section class="about-page-area section_70" style="background-color: white;">

         <div class="container">

         

            <div class="row">

            <?php

            $sl = 1;

$get = mysql_query("SELECT * FROM `gallery` ORDER BY `i_id` DESC ");

while($data = mysql_fetch_array($get)){

?>

                <div class="col-lg-3">

                  <div class="about-page-left">

    <a class="example-image-link" href="images/<?php echo $data["i_image"];?>" data-lightbox="example-set" data-title="Click anywhere outside the image or the X to the right to close."><img id="imgTest" class="example-image img-thumbnail" src="images/<?php echo $data["i_image"];?>" alt="" style="width:230px; height:180px; margin:10px;"/></a>

                  </div>

                </div>

                <?php

                //$sl++;

            }

            ?>

            </div>

            

         </div>

      </section>

      <!-- About Page Area End -->

       



<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.0/js/lightbox.js"></script>


<?php

include("footer.php");

?>


Read More

Upload an Image Using PHP and MySQL with Stylish UI Design

Upload an Image Using PHP and MySQL with Stylish UI Design: 

For uploading an image, the html form should be like this.

<form action="" method="post" enctype="multipart/form-data"></form>

Some rules to follow for the HTML form above:

  • Make sure that the form uses method="post" 
  • The form also needs the following attribute: enctype="multipart/form-data". It specifies which content-type to use when submitting the form 
Without the requirements above, the file upload will not be working. 

Other things to notice: 
  • The type="file" attribute of the <input> tag shows the input field as a file-select control, with a "Browse" button next to the input control 

Creating an upload script:

For uploading an image the $_FILES is a global variable. This variable is an associate double dimension array and keeps all the information related to uploaded file. PHP can create another five following variable:
  • $_FILES['file']['tmp_name'] − Stores the name of the temporary file.
  • $_FILES['file']['name'] − Stores the original filename from the client. 
  • $_FILES['file']['size'] − the size in bytes of the uploaded file. 
  • $_FILES['file']['type'] − the MIME type of the uploaded file. 
  • $_FILES['file']['error'] − the error code associated with this file upload.
Using $_FILES['file']['tmp_name'], Your file will temporary store on this path $_FILES['image_path']['tmp_name']. so when you move it will be remove from temp folder to your folder. If you use copy command instead of move_uploaded_file then your temp file will be stay in your server's temp folder. you can search file name in there.

Upload an Image into database using PHP and MySQL:

<!--HTML form design for uploading an Image-->
<html> 
<head> 
<title>Upload an Image into database using PHP and MySQL</title> 
</head> 
<body> 
<form action =" " method = "POST" enctype = "multipart/form-data"> 
<div class = "form-group">
<label>Select an Image</label>
<input class = "form-control"  name = "c_pic" type = "file" />
<input type = "submit" value = "Upload" class = "btn btn-sm btn-success pull-right"> 
</div>
</form>

<!--PHP script for uploading an image--> <?php
$c_pic = $_FILES["c_pic"]["name"];

if($_FILES["c_pic"]["name"] == Null) {
$c_pic = ""; 
}else{ 
$c_pic = date('Ymdhis'); 
$c_pic = $c_pic.".jpg"; 
@move_uploaded_file($_FILES["c_pic"]["tmp_name"], "UploadFolder/$c_pic"); 

}

$insert=mysql_query("INSERT INTO `customer` ( `c_image`) VALUES ('$c_pic')");
?>

Show the uploaded image from Database:

<table class= "table">
<thead>
<tr>
<th>Serial No</th>
<th>Image</th>
</tr>
</thead>

<tbody>
<?php 
$si = 1;
$uid = 10; 
$qry = mysql_query("SELECT * FROM `customer` WHERE `c_id`='$uid'");          
while( $res = mysql_fetch_array($qry)){
//echo $res['c_image']; 
echo "<tr>";
echo "<td>".$si++."</td>";
echo "<td>";
echo "<img src = 'UploadFolder/$res[c_image]' height='500px' width='500px' class='img-thumbnail img-fluid'>"; 
echo "</td>";
echo "</tr>";
}
?>
</tbody>
</table>

Upload an Image into database with file validation:

<?php
if(isset($_FILES['image'])){
$error = array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext = strtolower(end(explode('.',$_FILES['image']['name'])));
      
$expension = array("jpeg","jpg","png");
      
if(in_array($file_ext,$expensions)=== false){
$error[]="extension not allowed, please choose a JPEG or PNG file.";
}
      
if($file_size > 2097152) {
$error[]='File size must be excately 2 MB';
}
      
if(empty($error)==true) {
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($error);
}
}
?>
<html>
<body>     
<form method = "POST" enctype = "multipart/form-data">
<input type = "file" name = "image" />
<input type = "submit"/>
<ul>
<li>Sent file: <?php echo $_FILES['image']['name'];  ?>
<li>File size: <?php echo $_FILES['image']['size'];  ?>
<li>File type: <?php echo $_FILES['image']['type'] ?>
</ul>
</form>
</body>
</html>

Image Uploading Using PHP and MySQL with Image Preview:

Image Uploading Using PHP and MySQL with Image Preview:

<?php
$c_pic = $_FILES["document_image"]["name"];
if($_FILES["document_image"]["name"] == Null) {
$c_pic=""; 
}else{ 
$c_pic=date('Ymdhis'); 
$c_pic=$c_pic.".jpg"; 
@move_uploaded_file($_FILES["document_image"]["tmp_name"], "../shop_images/$c_pic"); 

}

$insert = $con->query("INSERT INTO `temporary_tax`(`shop_id`, `document_image`) VALUES ('13', '$c_pic') ");
?>
<html> 
<head> 
<title>Upload an image</title> 
</head> 
<body> 

<div class="form-group"> 
<label class="text-label">Document File</label>
<br>
<img class="form-control-file" id="showImage" src="Upload/legal_documents/document.png" width="150px" height="200px">
<br>
<input type="file" class="form-control" name="document_image" onchange="readURL(this);">
</div>
</body>
</html>

<!--Script for image preview with upload-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();

reader.onload = function (e) {
$('#showImage').attr('src', e.target.result);
}

reader.readAsDataURL(input.files[0]);
}
}
</script>

<!--Script for image preview with upload-->

Image Uploading with allowed file extension using PHP and MySQL:

<!DOCTYPE>
<html>
<head>
<title>Uploading an image with allowed file extension using PHP and MySQL</title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="imageToUpload" id="imageToUpload">
<input type="submit" value="Upload Image" name="save">
</form>
</body>
</html>

<?php
if (isset($_POST["save"])) {

// create an array with allowed file extension
$allowed = array('gif', 'png', 'jpg');
$filename = $_FILES['imageToUpload']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (!in_array($ext, $allowed)) {
echo 'This file extension is not allowed';
}else{
echo "This file extension is allowed";
}
}
?>

File upload UI Design Bootstrap:

File upload UI Design Bootstrap:
Using the following code sample you can easily create the above image upload UI design.

<!DOCTYPE>
<html>
<head>
<title>File upload UI Design Bootstrap</title>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<label><b>Upload Image</b></label><br>
<label>
<input type='file' onchange="readURL(this);" style="display:none"/>
<img id="showImage" src="img/plus.png" style="width: 100px; height: 100px; background-color: red; border: 2px solid red; border-radius: 5px; cursor: pointer;"/> 
</label><i class="fa-file-image-o" aria-hidden="true"></i>
</form>
</body>
</html>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script> 
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#showImage').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>

Drag and Drop Design for file Upload Image:
Drag and Drop file Upload

<!DOCTYPE html>
<html>
<head>
<title>Custom File Upload Drag and Drop</title>
<style> 
body {
font-family: sans-serif;
background-color: #eeeeee;
}
.file-upload {
background-color: #ffffff;
width: 600px;
margin: 0 auto;
padding: 20px;
}

.file-upload-button {
width: 100%;
margin: 0;
color: #fff;
background: #1FB264;
border: none;
padding: 10px;
border-radius: 4px;
border-bottom: 4px solid #15824B;
transition: all .2s ease;
outline: none;
text-transform: uppercase;
font-weight: 700;
}

.file-upload-button:hover {
background: #1AA059;
color: #ffffff;
transition: all .2s ease;
cursor: pointer;
}

.file-upload-button:active {
border: 0;
transition: all .2s ease;
}

.file-upload-content-area {
display: none;
text-align: center;
}

.file-upload-input-field {
position: absolute;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
outline: none;
opacity: 0;
cursor: pointer;
}

.image-upload-area {
margin-top: 20px;
border: 4px dashed #1FB264;
position: relative;
}

.image-dropping,
.image-upload-area:hover {
background-color: #1FB264;
border: 4px dashed #ffffff;
}

.image-title-wrap {
padding: 0 15px 15px 15px;
color: #222;
}

.drag-text {
text-align: center;
}

.drag-text h3 {
font-weight: 100;
text-transform: uppercase;
color: #15824B;
padding: 60px 0;
}

.file-upload-image {
max-height: 200px;
max-width: 200px;
margin: auto;
padding: 20px;
}

.remove-image {
width: 200px;
margin: 0;
color: #fff;
background: #cd4535;
border: none;
padding: 10px;
border-radius: 4px;
border-bottom: 4px solid #b02818;
transition: all .2s ease;
outline: none;
text-transform: uppercase;
font-weight: 700;
}

.remove-image:hover {
background: #c13b2a;
color: #ffffff;
transition: all .2s ease;
cursor: pointer;
}

.remove-image:active {
border: 0;
transition: all .2s ease;
}
</style>
</head>
<body>
<div class="file-upload">
<button class="file-upload-button" type="button" onclick="$('.file-upload-input-field').trigger( 'click' )">Upload Image</button>

<div class="image-upload-area">
<input class="file-upload-input-field" type='file' onchange="readURL(this);" accept="image/*" />
<div class="drag-text">
<h3>Drag and drop a Image or Upload Image</h3>
</div>
</div>
<div class="file-upload-content-area">
<img class="file-upload-image" src="#" alt="your image" />
<div class="image-title-wrap">
<button type="button" onclick="removeUpload()" class="remove-image">Remove <span class="image-title">Uploaded Image</span></button>
</div>
</div>
</div>
</body>
</html>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script> 
function readURL(input) {
if (input.files && input.files[0]) {

var reader = new FileReader();

reader.onload = function(e) {
$('.image-upload-area').hide();

$('.file-upload-image').attr('src', e.target.result);
$('.file-upload-content-area').show();

$('.image-title').html(input.files[0].name);
};

reader.readAsDataURL(input.files[0]);

} else {
removeUpload();
}
}

function removeUpload() {
$('.file-upload-input-field').replaceWith($('.file-upload-input-field').clone());
$('.file-upload-content-area').hide();
$('.image-upload-area').show();
}
$('.image-upload-area').bind('dragover', function () {
$('.image-upload-area').addClass('image-dropping');
});
$('.image-upload-area').bind('dragleave', function () {
$('.image-upload-area').removeClass('image-dropping');
});

</script>


Read More

Data Table with Empty Cell

Data Table with Empty Cell using php laravel

Array:

<?php 
    $a = ['IUBAT'];
    //echo $a[0];
?>

CSS Files:

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css">

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css">

JavaScript Files:

<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js
"></script>

<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>

<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $('#example').DataTable();
    } );
</script>

Full Code:

<?php
    
    $a = ['IUBAT'];
    //echo $a[0];
?>

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css">
</head>
<body>
    <table id="example" class="table table-hover table-bordered" style="width:100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Age</th>
                <th>University 1</th>
                <th>University 2</th>
                <th>University 3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Amit</td>
                <td>Programmer</td>
                <td>25</td>
                <?php
                    if (count($a) == 3) {                    
                    
                        foreach ($a as $value) {
                            echo "<td>";
                            echo $value;
                            echo "</td>";                      
                        }
                    }elseif(count($a) == 2){
                       foreach ($a as $value) {
                            echo "<td>";
                            echo $value;
                            echo "</td>";                      
                        }
                        echo "<td>"."</td>";
                    }elseif(count($a) == 1){
                         foreach ($a as $value) {
                            echo "<td>";
                            echo $value;
                            echo "</td>";                      
                        }
                        echo "<td>"."</td>";
                        echo "<td>"."</td>";
                    }
                ?>                
            </tr>
        </tbody>   
    </table>
</body>
</html>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js
"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $('#example').DataTable();
    } );
</script>

Result:

Data Table with Empty Cell

Read More