<input id="user_name" type="text" pattern="[a-zA-Z0-9]{2,64}" name="user_name" required class="form-control" value="<?php if(isset($_POST['user_name'])) { echo htmlentities ($_POST['user_name']); }?>" />
PHP Display date and time now according to your country (Server time change)
<?php
date_default_timezone_set('Asia/Colombo'); //your country region
http://php.net/manual/en/timezones.php
$timenow = date('H:i:s', time());
$datenow = date('Y-m-d');
?>
date_default_timezone_set('Asia/Colombo'); //your country region
http://php.net/manual/en/timezones.php
$timenow = date('H:i:s', time());
$datenow = date('Y-m-d');
?>
Jquery select radio button group value and if else
$("input:radio[name=group1]").click(function() {
var value = $(this).val();
//alert(value);
if(value==='homedelivery'){
$('#payncolcontent').hide();
$('#cashndrcontent').fadeIn();
//alert("222");
}
else if(value==='pickupfromstore'){
//alert("111111");
$('#cashndrcontent').hide();
$('#payncolcontent').fadeIn();
}
});
var value = $(this).val();
//alert(value);
if(value==='homedelivery'){
$('#payncolcontent').hide();
$('#cashndrcontent').fadeIn();
//alert("222");
}
else if(value==='pickupfromstore'){
//alert("111111");
$('#cashndrcontent').hide();
$('#payncolcontent').fadeIn();
}
});
PHP OOP PDO Database class example
Read / fetch data with PHP PDO Database Connection Class in Simple way
<?php
class db {
private $username = "root";
private $password = "";
function connect() {
$username = $this->username;
$password = $this->password;
try {
$conn = new PDO('mysql:host=localhost;dbname=test', $username, $password);
} catch (Exception $ex) {
die($ex->getMessage());
}
return $conn;
}
}
class getdata extends db {
function read() {
$con = $this->connect();
$sql = "SELECT * FROM CITY";
try {
$citylist = $con->query($sql);
} catch (Exception $ex) {
}
return $citylist;
}
}
$getdataCity = new getdata();
$citylist = $getdataCity->read();
$a = $citylist->fetchAll();
print_r($a);
if($citylist->rowCount()){
foreach ($a as $city){
echo $city['city_name'];
}
}
class db {
private $username = "root";
private $password = "";
function connect() {
$username = $this->username;
$password = $this->password;
try {
$conn = new PDO('mysql:host=localhost;dbname=test', $username, $password);
} catch (Exception $ex) {
die($ex->getMessage());
}
return $conn;
}
}
class getdata extends db {
function read() {
$con = $this->connect();
$sql = "SELECT * FROM CITY";
try {
$citylist = $con->query($sql);
} catch (Exception $ex) {
}
return $citylist;
}
}
$getdataCity = new getdata();
$citylist = $getdataCity->read();
$a = $citylist->fetchAll();
print_r($a);
if($citylist->rowCount()){
foreach ($a as $city){
echo $city['city_name'];
}
}
Enable and Disable JQuery UI accordion rows
Enable and Disable and selecting JQuery UI accordion rows
$('#sdx').click(function(){
$("#accordion").accordion({
active: 0,
});
$('.ui-accordion-header').addClass('ui-state-disabled').on('click', function () {
return false;
});
$('.ui-accordion-header').eq(0).removeClass('ui-state-disabled').on('click', function () {
return true;
});
});
$('#sdx').click(function(){
$("#accordion").accordion({
active: 0,
});
$('.ui-accordion-header').addClass('ui-state-disabled').on('click', function () {
return false;
});
$('.ui-accordion-header').eq(0).removeClass('ui-state-disabled').on('click', function () {
return true;
});
});
Subscribe to:
Posts (Atom)