sondmk header
การเขียนโปรแกรมด้วยภาษา PHP เบื้้องต้น

Learn PHP MVC

Post by Goborijung at 2023-02-28 23:58:22 | ID: 1864

https://www.studentstutorial.com/php/mvc/mvc-hello-world.php

OOP Programming

Post by Goborijung at 2023-05-22 14:33:55 | ID: 1912

www.borntodev.com/2020/04/14/oop-จากตัวอย่างที่ง่ายๆ/

PHP : Class objControl

Post by Goborijung at 2020-09-23 02:17:19 | ID: 816

<?php
	class objControl
	{
		public function getColumns($arrColName)
		{
			echo "<thead><tr class='bg-primary'>";
			foreach($arrColName as $val)
			{
				switch($val)
				{
					case "#" 			: echo "<th width='1%'>".$val."</th>"; 	break;
					case "จัดการ" 	: echo "<th width='5%'>".$val."</th>"; 	break;
					default 			: echo "<th>".$val."</th>"; 						break;
				}
			}
			echo "</tr></thead>";
		}
	}

	// Use Class
	$objControl = new objControl();
	$objControl->getColumns(array('#','จัดการ','ชื่อ','ประเภท','วันที่เขียน'));
?>

PHP : Create Variable by Method POST | สร้างตัวแปรแบบ Array ด้วย Method POST

Post by Goborijung at 2020-04-02 11:33:06 | ID: 456

<?php
	/* Create Variable by Method POST */
	$arrVar = array(
		'ItemType'
		,'IDCode'
		,'Description'
		,'LotNo'
		,'PONo'
		,'InvoiceNo'
		,'Customer'
		,'CRNo'
		,'DocumentNo'
		,'DocumentDate'
	);

	foreach($arrVar as $val)
	{
		${$val} = issetPOST($val);
	}

	/* Show Variable Value */
	foreach($arrVar as $val)
	{
		echo $val." : <span class='text-danger'>".${$val}."</span> | ";
	}
	echo '<br>';
?>

PHP : Date -1 Month , strtotime

Post by Goborijung at 2020-04-20 09:27:59 | ID: 501

<?php
$currentDate = date("Y-m-d");
$fixDate = "2020-06-20";
echo date("Y-m-d",strtotime($currentDate."-1 month")).'<br>';
echo date("Y-m-d",strtotime($fixDate."-1 month"));
?>

PHP : Network Programming

Post by Goborijung at 2020-04-11 15:02:31 | ID: 493

https://corpocrat.com/2009/03/01/php-script-to-check-server-status-onlineoffline/
https://www.phpservermonitor.org/
https://www.thaicreate.com/php/forum/088321.html
http://www.thecave.info/php-ping-script-to-check-remote-server-or-website/
https://www.sitepoint.com/community/t/how-to-show-if-server-is-online-or-offline/1454/2
https://fam.tuwien.ac.at/~schamane/_/netstat_php

PHP : Scan Filename in Dir Or Directory

Post by Goborijung at 2020-10-16 16:38:11 | ID: 381

<?php
	$dir    = '../uploads';
	$objOpen = opendir($dir);
	$count = 1;
	while (($file = readdir($objOpen)) !== false)
	{
		if (($file == ".") or ($file == "..")) continue;
		echo is_dir($file)? "Directory" : "filename", " : " ,  $file ,  "<br>";
		$count++;
	}
	echo 'Files Count: '.($count-1).' Items';
?>


<?php $dir = './'; $objOpen = opendir($dir); $count = 1; while (($file = readdir($objOpen)) !== false) { if (($file == ".") or ($file == "..")) { continue; } if(is_dir($file)) { echo "dir : ".$file.'<br>'; } else { echo "fname : ".$file.'<br>'; } $count++; } echo 'Files Count: '.($count-1).' Items'; ?>

PHP : ajax crud , php crud

Post by Goborijung at 2022-06-21 09:04:20 | ID: 1604

test

PHP : Ajax Delete , Delete table row

Post by Goborijung at 2022-06-14 08:05:40 | ID: 1592

>> a.php

<?php 
include 'config/config.php';
$funcao="Select * From tblUser";
$result=odbc_exec($connection, $funcao);
?>

<?php  if(odbc_num_rows($result) > 0)  { ?>

<table class="table">
    <tr>
        <th>IdPalavra</th>
        <th>UserName</th>
        <th>Action</th>
    </tr>


    <?php while($row = odbc_fetch_array($result)) { ?>

    <tr role="row" class="palavras_row">
        <td><?php echo $row['OID']; ?></td>
        <td><?php echo $row['UserName']; ?></td>
        <td><a href="javascript:void(0);" class="palavras_delete" data-id="<?php echo $row['OID']; ?>">Delete</a>
        </td>
    </tr>
    <?php } ?>
</table>

<?php } ?>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js?ver=3.3.1"></script>
<script type="text/javascript">
(function($) {
    $(document).on('click', '.palavras_row a.palavras_delete', function() {
        var _id = $(this).attr('data-id');
        var _row = $(this).parent().parent();
        if (confirm("del?")) {
            $.ajax({
                url: 'b.php',
                type: 'POST',
                data: {
                    'oid': _id,
                },
                dataType: 'json',
                success: function(__resp) {
                    if (__resp.success) {
                        _row.remove(); // Deletes the row from the table
                    }
                }
            });
        }
    });
})(jQuery);
</script>

----------------------------------------------------------------------

>> b.php

<?php
$oid = filter_input(INPUT_POST, 'oid', FILTER_SANITIZE_NUMBER_INT);
$success = false;
if ($oid) {
    include 'config/config.php';  //connection to database 
    $funcao="delete from tblUser where oid = " . $oid;
    $result=odbc_exec($connection, $funcao);
    $success = true;
}
header('Content-Type: application/json');
echo json_encode(array('success' => $success));
?>



PHP : Check Login Page in Master Page (Index.php)

Post by Goborijung at 2021-05-13 13:32:58 | ID: 1187

/*
	หน้า Index.php
	เมื่อเข้ามาที่หน้าแรก ให้ทำการเช็ค Session User Login
	- ถ้ายังไม่ได้ Login ให้ Redirect ไปที่หน้า Login ก่อน
	- แต่ถ้าหากมีการ Login และได้ Session Login มาแล้วถึงจะยอมให้เข้าถึงหน้านี้ได้
*/

<?php
	// เช็ค Session User Login
	session_start();
	if($_SESSION['user_login_id']=='')
	{
		header("Location: https://soundmk.com/admin/Admin-LTE/login");
		exit;
	}
?>

<html>
	<body>
		xxx
	</body>
</html>

12345678910...>>>

Framework

Library


เครื่องมือพัฒนาเว็บ



การออกแบบและพัฒนาเว็บไซต์


Download SourceCode



copyAllright © 2016 soundmk.com