Category Archives: PHP Code

PHP Code

enable sql_mode=only_full_group_by

root# nano /etc/mysql/my.cnf

 

# The MySQL database server configuration file.
#
# You can copy this to one of:
# – “/etc/mysql/my.cnf” to set global options,
# – “~/.my.cnf” to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with –help to get a list of available options and with
# –print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with ‘.cnf’, otherwise they’ll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
# … other stuff will probably be here
sql_mode = “STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION”
group_concat_max_len=2000000

——————————————

root#/etc/init.d/mysql restart

OK work

phpmyadmin connet MySQL 8.0

  1. MySQL Commands Login# mysql -u root -p
  2. Create User # CREATE USER ‘user’@’localhost’ IDENTIFIED BY ‘12345678’;
  3. Add Privileges # GRANT ALL PRIVILEGES ON . TO ‘user’@’localhost’;
  4. Change Password# ALTER USER ‘user’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘12345678’;

 

download phpmyadmin https://www.phpmyadmin.net/downloads/

save file config.inc.php    in phpmyadmin  folder

code :

<?php
/**
* Generated configuration file
* Generated by: phpMyAdmin 5.2.0 setup script
* Date: Tue, 10 Jan 2023 07:41:49 +0000
*/

/* Servers configuration */
$i = 0;

/* Server: 127.0.0.1 [1] */
$i++;
$cfg[‘Servers’][$i][‘verbose’] = ”;
$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;
$cfg[‘Servers’][$i][‘port’] = ”;
$cfg[‘Servers’][$i][‘socket’] = ”;
$cfg[‘Servers’][$i][‘auth_type’] = ‘cookie’;
$cfg[‘Servers’][$i][‘user’] = ‘user’;
$cfg[‘Servers’][$i][‘password’] = ‘12345678’;

/* End of servers configuration */

$cfg[‘blowfish_secret’] = ‘VZP.$U_vB#G\\;>q-r]qY=9<&6(\\GB1S1’;
$cfg[‘DefaultLang’] = ‘en’;
$cfg[‘ServerDefault’] = 1;
$cfg[‘UploadDir’] = ”;
$cfg[‘SaveDir’] = ”;

 

Code ตัวอย่าง PHP จํากัดตัวอักษรในการแสดงผล ด้วยคำสั่ง mb_strimwidth

ตัวอย่าง PHP จํากัดตัวอักษรในการแสดงผล ด้วย mb_strimwidth

<?php
    $string = "PHP จํากัดตัวอักษรในการแสดงผล ด้วย mb_strimwidth";
    echo mb_strimwidth( $string, 0, 20, "..." );
?>

ผลลัพธ์

PHP จํากัดตัวอักษ...

php DateThai แปลงจากตัวเลขวันที่ ให้เป็น ปี เดือน ไทย

<?php

function DateThai($strDate)
{
$strYear = date(“Y”,strtotime($strDate))+543;
$strMonth= date(“n”,strtotime($strDate));
$strDay= date(“j”,strtotime($strDate));
$strHour= date(“H”,strtotime($strDate));
$strMinute= date(“i”,strtotime($strDate));
$strSeconds= date(“s”,strtotime($strDate));
$strMonthCut = Array(“”,”มกราคม” , “กุมภาพันธ์” , “มีนาคม” , “เมษายน” , “พฤษภาคม” , “มิถุนายน” , “กรกฏาคม” , “สิงหาคม” , “กันยายน” , “ตุลาคม” ,”พฤศจิกายน” , “ธันวาคม” );

Continue reading

Bootstrap 3 Modals box code php

Test Bootstrap 3 Modals box code php

  1. สร้าง File  index.php  

code #

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title>Example of Bootstrap 3 Modals</title>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css”>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css”>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>
<script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script>
<style>
.container {
padding-left: 15px;
padding-right: 15px;
}
</style>
</head>
<body>
<div class=”container “>
<div class=”jumbotron”><a class=”btn btn-primary pull-right” data-toggle=”modal” href=”#myModal” id=”modellink”>Show Modal</a></div>
<div class=”modal-container”></div>
</div>
</body>
</html>
<script type=”text/javascript”>
$(document).ready(function(){
var url = “modalbox.php”;              //url  สำหรับ link  popup 
jQuery(‘#modellink’).click(function(e) {
$(‘.modal-container’).load(url,function(result){
$(‘#myModal’).modal({show:true});
});
});
});
</script> Continue reading