Skip to content

Instantly share code, notes, and snippets.

View ErMandeep's full-sized avatar
🎯
Focusing

Mandeep Singh ErMandeep

🎯
Focusing
View GitHub Profile
@ErMandeep
ErMandeep / onclick confirm javascipt
Created January 12, 2019 04:43
onclick confirm javascipt
<a href="delete.php?id=22" onclick="return confirm('Are you sure?')">Link</a>
@ErMandeep
ErMandeep / query for show same data in one time fetch from databse
Created January 29, 2019 10:42
query for show same data in one time fetch from databse
$query = "SELECT type
FROM budget
WHERE coupleID = '$login_id'
GROUP BY type
HAVING COUNT(type) >=1";
$result = mysqli_query($connection, $query);
// suppose you have 3 times same car in databse column this only show one time
@ErMandeep
ErMandeep / show dublicate column value 1 time and sum of that all value in same place
Created January 30, 2019 05:30
Show mutliple same database colomn value in 1 time , further sum of that particular column values and show them right now.
Show mutliple same database colomn value in 1 time , further sum of that particular column values and show them right now.
<?php
$login_id = "";
if (isset($_SESSION['coupleID'])) {
$login_id = $_SESSION['coupleID'];
}
$query = "SELECT type, estimate, actual, paid , pending
FROM budget
WHERE coupleID = '$login_id'
@ErMandeep
ErMandeep / gist:ebd369e40ed360c0319f4be4105ea89f
Last active January 30, 2019 09:58
upload/delete/fetch multiple images using array
<form method="Post" enctype="multipart/form-data">
<input type="file" name="file[]" multiple>
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])) {
$j = 0; // Variable for indexing uploaded image.
@ErMandeep
ErMandeep / gist:89ffbd955614abb821129a678c7d7271
Created January 31, 2019 10:14
rewite url from http://localhost/realwed/couples.php?username=demo to http://localhost/realwed/couples/demo
rewite url from http://localhost/realwed/couples.php?username=demo to http://localhost/realwed/couples/demo
.htaccess // create file
RewriteEngine On
RewriteRule ^([a-z0-9]+)$ couple.php?username=$1 [QSA,L]
@ErMandeep
ErMandeep / gist:0d885ff29de1f42fe23fa244f62dfc16
Last active February 1, 2019 04:38
db connection on server
<?php
$db['db_host'] = "localhost:3306";
$db['db_user'] = "enterusername";
$db['db_pass'] = "enterpass";
$db['db_name'] = "dbname";
foreach ($db as $key => $values ){
define(strtoupper($key), $values);
}
@ErMandeep
ErMandeep / php file upload errors
Created February 27, 2019 13:27
check the file upload error using array (8 errors of files)
<?php
if(isset($_POST['submit'])){
echo "<pre>";
print_r($_FILES['file_upload']);
echo "</pre>";
$upload_error = array(
@ErMandeep
ErMandeep / gist:929e783ba9ab12598a5ffcb841d85999
Created February 27, 2019 13:40
upload file into folder simple method and show error if any
<?php
if(isset($_POST['submit'])){
echo "<pre>";
print_r($_FILES['file_upload']);
echo "</pre>";
$upload_error = array(
<?php
if(isset($_GET['pid'])){
$pid = $_GET['pid'];
}
$id = base64_decode($pid);
echo $id;
@ErMandeep
ErMandeep / gist:e79108b714d6f5534a0acefe45e7cbcd
Created March 6, 2019 09:26
click event for getting data-id from attr in ahref url
setTimeout(function(){
console.log("I entered");
jQuery( document ).on('click' , '.duplicate' , function(e){
e.preventDefault();
var dd = jQuery(this).attr('data-id');
console.log(dd);
});