วันจันทร์ที่ 29 เมษายน พ.ศ. 2556

การเขียน Array เที่ยบค่าเพื่อแสดงผล



$mydam = 1; //หมายถึงค่าที่ถูก Post มาจาก Form  $_POST['mydam'];
$damx = array("เขื่อนภูมิพล", "เขื่อนสิริกิติ์", "เขื่อนศรีนครินทร์", "เขื่อนท่าทุ่งนา", "เขื่อนวชิราลงกรณ", "เขื่อนรัชชประภา", "เขื่อนบางลาง", "เขื่อนแก่งกระจาน", "เขื่อนอุบลรัตน์", "เขื่อนสิรินธร", "เขื่อนจุฬาภรณ์", "เขื่อนปากมูล", "เขื่อนน้ำพุง", "เขื่อนห้วยกุ่ม", "โรงไฟฟ้าลำตะคอง", "เขื่อนแม่งัด", "โรงไฟฟ้าบ้านขุนกลาง", "โรงไฟฟ้าบ้านยาง", "โรงไฟฟ้าห้วยกุยมั่ง", "","โรงไฟฟ้าบ้านสันติ"); //กำหนด ค่าของ Array โดย Array จะเริ่มต้นที่ 0

$myd =round($mydam)-1;  //ค่าที่ส่งมาต้อง - 1 กรณีที่ค่าที่ Post มาเริ่มต้นที่ 1 //round กำหนดให้เป็นตัวเลขจำนวนเต็ม
$mydam1 =$damx[$myd]; // กำหนดให้เที่ยบค่าที่ Post มากับที่ Array ที่กำหนดไว้

ผลลัพธ์ 
          echo $mydam1  ;  // คำตอบคือ เขื่อนภูมิพล

PHP Function BBCode2HTML

<?php
// function to convert bbcode, and smiles to html
function bbcodeHtml($str) {
  // delete 'http://' because will be added when convert the code
  $str = str_replace('[url=http://', '[url=', $str);
  $str = str_replace('[url]http://', '[url]', $str);

  // Array with RegExp to recognize the code that must be converted
  $bbcode_smiles = array(
    // RegExp for [b]...[/b], [i]...[/i], [u]...[/u], [block]...[/block], [color=code]...[/color], [br]
    '/\[b\](.*?)\[\/b\]/is',
    '/\[i\](.*?)\[\/i\]/is',
    '/\[u\](.*?)\[\/u\]/is',
    '/\[block\](.*?)\[\/block\]/is',
    '/\[color=(.*?)\](.*?)\[\/color\]/is',
    '/\[br\]/is',

    // RegExp for [url=link_address]..link_name..[/url], or [url]..link_address..[/url]
    '/\[url\=(.*?)\](.*?)\[\/url\]/is',
    '/\[url\](.*?)\[\/url\]/is',

    // RegExp for [img=image_address]..image_title[/img], or [img]..image_address..[/img]
    '/\[img\=(.*?)\](.*?)\[\/img\]/is',
    '/\[img\](.*?)\[\/img\]/is',

    // RegExp for sets of characters for smiles: :), :(, :P, :P, ...
    '/:\)/i', '/:\(/i', '/:P/i', '/:S/i', '/:O/i', '/=D\>/i', '/\>:D\</i', '/:D/i', '/:-\*/i'
  );

  // Array with HTML that will replace the bbcode tags, defined inthe same order
  $html_tags = array(
    // <b>...</b>, <i>...</i>, <u>...</u>, <blockquote>...</blockquote>, <span>...</span>, <br/>
    '<b>$1</b>',
    '<i>$1</i>',
    '<u>$1</u>',
    '<blockquote>$1</blockquote>',
    '<span style="color:$1;">$2</span>',
    '<br/>',

    // a href...>...</a>, and <img />
    '<a target="_blank" href="http://$1">$2</a>',
    '<a target="_blank" href="http://$1">$1</a>',
    '<img src="$1" alt="$2" />',
    '<img src="$1" alt="$1" />',

    // The HTML to replace smiles. Here you must add the address of the images with smiles
    '<img src="icos/1.gif" alt=":)" border="0" />',
    '<img src="icos/2.gif" alt=":(" border="0" />',
    '<img src="icos/3.gif" alt=":P" border="0" />',
    '<img src="icos/4.gif" alt=":S" border="0" />',
    '<img src="icos/5.gif" alt=":O" border="0" />',
    '<img src="icos/6.gif" alt="=D&gt;" border="0" />',
    '<img src="icos/7.gif" alt="&gt;: D&lt;" border="0" />',
    '<img src="icos/8.gif" alt=": D" border="0" />',
    '<img src="icos/9.gif" alt=":-*" border="0" />'
  );

  // replace the bbcode
  $str = preg_replace($bbcode_smiles, $html_tags, $str);

  return $str;
}

// Test
$str = 'Test [b]PHP tutorials[/b].[br]
[i][color=blue]Blue, and oblique string[/color][/i], underlined: [u]BBCODE tags[/u][br]
Link: [url=http://coursesweb.net/php-mysql/]PHP Course[/url], smiles: =D>, :), >:D< ...
[block]Text added in "block", for blockquote[/block]
An image: [img=http://coursesweb.net/imgs/webcourses.gif]Course Web[/img]';

echo bbcodeHtml($str);
?>

วันอาทิตย์ที่ 28 เมษายน พ.ศ. 2556

Chartdirector แสดงผลภาษาไทย

Chartdirector
แสดงผลภาษาไทย กรณีที่หน้า Webpage Encode UTF-8 จะไม่มีปัญหาในการแสดงผล
แต่ถ้าเลือกเป็น Windows-874 หรือ TIS-620 จะมีปัญหาในการแสดงกราฟ
วิธีแก้
ใช้
         ICONV('TIS-620','UTF-8',$ตัวแปร)

ตัวอย่าง
$labelsObj = $c->xAxis->setLabels($labels);
$labelsObj->setFontAngle(0);
$labelsObj->setFontColor(0X0000ff );
$labelsObj->setFontStyle("tahoma.ttf", 6);
$title1 =   iconv('TIS-620','UTF-8',"ข้อมูล".$captions);
$c->xAxis2->setTitle($title1, "tahoma.ttf", 18,0X0000ff);
if($chart_type == "line"){
$layer = $c->addLineLayer2();
$layer1 = $c->addLineLayer2();
$layer2 = $c->addLineLayer2();
#Set the default line width to 2 pixels
$layer1->setLineWidth(1);
$layer->setLineWidth(3);
$layer2->setLineWidth(3);
$c->xAxis->setWidth(1);
$dataSetObj = $layer->addDataSet($data1, 0x0000c0, iconv( 'TIS-620','UTF-8',"ข้อมูลปี ".$end_year));
$dataSetObj->setDataSymbol(CircleSymbol, 9, 0xffff00);
$dataSetObj2 = $layer2->addDataSet($data2, $c->dashLineColor(0x00FF00, DashLine),iconv( 'TIS-620','UTF-8',"เทียบกับการใช้ ปี ".($start_year)));
$dataSetObj2->setDataSymbol(CircleSymbol, 8, 0x99FFCC);
$c->addAreaLayer($data3, $c->gradientColor(0, 2000, 00, 5000, 0xFFCCCC, 0xFF3333),iconv( 'TIS-620','UTF-8',"เทียบกับการใช้ ปี ".($start_year)."ลดลงอีก ".$p_energy ."%"));

** ใช้ ICONV() ถ้าใช้ WINDOWS-874 ไม่ต้องเปลี่ยนให้ใช้ TIS-620 อันเดียวเลย

วันพฤหัสบดีที่ 28 มีนาคม พ.ศ. 2556

หาจำนวนวัน ในเดือน ของปีใด ๆ


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  A
  <input name="a" type="text" id="a" />
  B
  <input name="b" type="text" id="b" />
  C
  <input name="c" type="text" id="c" />
  <input type="submit" name="Submit" value="Submit" />
</form>
<?
function get_days_in_month($month, $year)
{
   return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year %400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
$myyear = date('Y');
echo get_days_in_month(2, $myyear);
?>
</body>
</html>

วันพฤหัสบดีที่ 27 ธันวาคม พ.ศ. 2555

Offline Install Antivirus 2013

กรุณาดาวน์โหลด โปรแกรมรุ่นที่คุณเลือกตอนลงทะเบียน เนื่องจาก Activation code ไม่สามารถใช้ร่วมกันได้ โปรแกรมหลักในหน้าลงทะเบียน คือ Panda Antivirus Pro 2013
panda antivirus pro 2013
Panda Internet Security 2013
  • Antivirus / Firewall
  • Antispam / Identity Protection
  • Parental Control
  • Backup & Restore
  • Multimedia/Gaming Mode
  • Home Network Manager
  • Remote PC Access
  • Panda Safe Browser (Sandboxing)
downloaduser guide

http://www.advice.co.th/panda/

Panda Internet Security 2013 - acs.pandasoftware.com/marketing/promo/IS13.exe

Kaspersky Internet Security 2013 - usa.kaspersky.com/files/?file=kis&lang=en&ver=2013&pn=Downloads+%7C+Produc t+Updates+%7C+Kaspersky+Internet+Security

AVG Internet Security 2013 - 32 bit - avg.com/us-en/download-file-x86-triisc

Norton Internet Security 2013 - buy-download.norton.com/downloads/2013/20.1/NISNAV/EN/NIS-TW-30-20-1-0-24-EN.exe

Quick Heal Internet Security 2013 - 32 bit - bitcast-maa1.bitgravity.com/quickheal/builds/2013/eval/is/QHISFT32.EXE

Bitdefender Internet Security 2013 - download.bitdefender.com/windows/desktop/i_security/2013/en-us/bitdefender_is_2013_32b.exe

GDATA Internet Security 2013 - in.gdatasoftware.com/?eID=PushFile&dl=2f2f6606b6%3AAFQADQI%3D

Trend Micro Internet Security 2013 - http://www.trendmicro.com/ftp/products/titanium/internet_security/TTi_6.0_MR_32bit.exe
Emsisoft Internet Security Pack
info: Emsisoft Internet Security Pack
download: http://download4.emsisoft.com/EmsisoftInternetSecuritySetup.exe
Only Internet Security download link is provided here.Want Antivirus or Total Security or 64 bit download link visit here.

วันจันทร์ที่ 3 ธันวาคม พ.ศ. 2555

การหาค่าระหว่างข้อมูล โดยการเอาค่า Diff ที่ใกล้เคียงกันมาแสดง

SELECT
  n2b.ids,
  n2b.levels,
  n2b.quantity
FROM
  n2b
WHERE
  n2b.levels = (select IF((tb1.uppers - 0.9)>(0.9 - tb2.lowers),tb2.levels,IF((tb1.uppers - 0.9)<(0.9 - tb2.lowers),tb1.levels,tb1.levels)) as sum_upper
from ((SELECT n2b.ids, n2b.levels, n2b.quantity as uppers FROM n2b WHERE
 n2b.quantity >= 0.9 limit 1) as tb1
     JOIN
     (SELECT n2b.ids, n2b.levels, n2b.quantity as lowers FROM n2b WHERE
      n2b.quantity <= 0.9 order by ids desc limit 1) as tb2))
ORDER BY
  ids DESC
LIMIT 1