Skip to content

Instantly share code, notes, and snippets.

@snowbob
snowbob / isValidMobileNumber.php
Created May 21, 2019 08:39
check if valid mobile phone number
<?php
$phones = array( '447549007599', '353852723831', '614549007599' , '615549007599' , '642549007599' , '918667672071');
#$phones = array( '448549007599');
function isValidMobileNumber($phones = null) {
$countryCode = array( '44' => '7', '353' => '8', '61' =>'4|5', '64' =>'2');
$result = array();
foreach( $phones as $number )
{
@snowbob
snowbob / gist:071df91f63299b1990a09450555a60c0
Created November 21, 2018 23:32
js:removeSpecialCharsOnBlur
$("input[id^='item-']").live('blur',function(e) {
var $this = $(this),
edit = '<?=$edit;?>',
str = $this.val()
str = str.replace(/[!£$^*]/gi, '');
str = removeTags(str);
$this.val(str)
get_name($this.attr('id'))
@snowbob
snowbob / gist:0b61a81997c844722621ff50f32dfea8
Created November 10, 2018 02:25
implde array to use in in query
while($row=mysql_fetch_assoc($result)) {
$users_array[]= "'".$row['user']."'";
}
$user_list = implode(',', $users_array);
$(document).on('focusin', 'input', function(){
console.log("Saving value " + $(this).val());
$(this).data('val', $(this).val());
}).on('change','input', function(){
var prev = $(this).data('val');
var current = $(this).val();
console.log("Prev value " + prev);
console.log("New value " + current);
});
$('a[data-toggle="tab"]').on('shown.bs.tab', function(e){
var currentTab = $(e.target).text(); // get current tab
var LastTab = $(e.relatedTarget).attr("href"); // get last tab
});
//echo datediff('w', '9 July 2003', '4 March 2004', false);
//Which will tell you the number of weekdays between the 9th July 2003 and the 4th of March 2004.
<?php
function datediff($interval, $datefrom, $dateto, $using_timestamps = false) {
/*
$interval can be:
yyyy - Number of full years
q - Number of full quarters
@snowbob
snowbob / resize iframe
Created November 28, 2016 06:49
resizeIframe
var iframe = parent.document.getElementById("memo").contentWindow;
var h = iframe.document.body.offsetHeight + 'px'
parent.$('#memo').css('height', h);
@snowbob
snowbob / bs:cardPayment
Created October 19, 2016 12:08
bootstrap container for card payment form
<div class="container">
<form class="form-horizontal" role="form">
<fieldset>
<legend>Payment</legend>
<div class="form-group">
<label class="col-sm-3 control-label" for="card-holder-name">Name on Card</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="card-holder-name" id="card-holder-name" placeholder="Card Holder's Name">
</div>
</div>
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
// output the column headings
fputcsv($output, array('Column 1', 'Column 2', 'Column 3'));
<?php
include('../../../connect.php');
include('../../../plugins/GUMP-master/gump.class.php');
$ERROR=0;
$gump = new GUMP();
$_POST = $gump->sanitize($_POST); // You don't have to sanitize, but it's safest to do so.