วันศุกร์ที่ 30 ตุลาคม พ.ศ. 2563

php seach in array multidimention

 Array

(
    [0] => Array
        (
            [id] => 7
            [name] => เงินเบิก 1
            [detail] => เงินเบิก
        )

    [1] => Array
        (
            [id] => 8
            [name] => เงินเบิก 2
            [detail] => ค่าเครื่องแบบ
        )

    [2] => Array
        (
            [id] => 9
            [name] => เงินเบิก 3
            [detail] => ประกันอุบัติเหตุ
        )

    [3] => Array
        (
            [id] => 10
            [name] => เงินเบิก 4
            [detail] => ร้านค้า
        )

    [4] => Array
        (
            [id] => 11
            [name] => เงินเบิก 5
            [detail] => ค่าอบรม
        )

)

 if( in_array($rd['id'], array_column($arrd, 'deduct_no'))){
 echo " checked=true"; 
 }

วันอังคารที่ 27 ตุลาคม พ.ศ. 2563

sweetalert2 show iframe disable "ok button" and "don't click outsize "


 swal.fire({ 

title:'เพิ่มวันหยุดประจำปี',

    width: 600,

  showCloseButton: true, //  show button X on top left

  showCancelButton: false,    /// show cancel

  showConfirmButton: false,  ///  show ok button

  allowOutsideClick: false,  /// don't click outsize

  onClose: Refreshs,     /// event on close 

    html: '<iframe src="holiday.php?_method=POST&date='+date+'" width="100%" height="500" src="" ></iframe>',

 }) ;


 function Refreshs() {

 

window.location.reload();

 }

วันเสาร์ที่ 17 ตุลาคม พ.ศ. 2563

create table on fly with ADD UNIQUE INDEX

 

 mysql_query("DROP TABLE IF EXISTS $table ") 
 mysql_query("CREATE TABLE $table select * from stock where 1 = 2 ") 
 
  mysql_query("ALTER TABLE `$table` ADD UNIQUE INDEX ( `code_no`)")

วันพฤหัสบดีที่ 15 ตุลาคม พ.ศ. 2563

validate input jquery

 <style>

 .error {

 border:solid red 1px;

 }

</style>


<input type="text" class="validate">

<script>

     $(".validate").each(function(i,v) {

   if(v.value ==  "") {

 $(this).addClass('error');

 

   }else{

 $(this).removeClass('error');      

   }

   

   });  


</script>