Search

Thursday, December 18, 2008

addslashes single quote and double quote

<?php
$old1 = 'H"s';
$old2 = "H's";
echo "new1 : " . addslashes ($old1);
echo "
";
echo "new2 : " . addslashes ($old2);
? >

The output :
new1 : H\"s
new2 : H\'s

Sunday, December 14, 2008

Spanning Tree Example

http://www.cisco.com/warp/public/473/spanning_tree1.swf

Finding prim number


#include < stdio.h>
#include < conio.h>
#include < math.h>
main()
{
int A,B,C=0,D;
printf("Program for finding Prime Number!\n\n\t you enter D=");
scanf("%d",&D);
printf("\nSo, prime number which is less than %d is...\n\n ",D);
printf("2\n");
for(A=3;A<=D;A+=2) { for(B=3;B<=sqrt(A);B+=2) {if(A%B==0) break;} if(B>sqrt(A))
{ printf("%d\n",A);
C+=1;
}

}

printf("\n\n\t***There are %d.\n\n\n\r",C+1);
getch();
}

Relational Database Normalization Examples 7/7

ตัวอย่าง 5.1 ตารางที่ยังไม่ทำ normalization (จากเอกสารของผู้ใช้ที่ส่งให้นักวิเคราะห์)
เป็นตารางการสั่งซื้อ ให้ท่านลองนำไปทำ normalization
orderid
301
orderdate
15/12/46
productid
401
402
quan
2
5
302 16/12/46 402
405
406
4
4
1
ตัวอย่าง 5.2 ตารางที่ยังไม่ทำ normalization (จากเอกสารของผู้ใช้ที่ส่งให้นักวิเคราะห์)
เป็นตารางเงินเดือน ให้ท่านลองนำไปทำ normalization
saleid
101




salesalary
2000
saleposition
sale
custid
201
202
203
204
custname
tom
dang
boy
girl
ตัวอย่าง 5.3 ใบเสร็จ 2 ใบ เลขที่ A0001 และ A0002 (ให้ท่านลองนำไปทำ normalization)
ตัวอย่างนี้ได้รับการเสนอแนะจาก sudomvon@minebea.co.th
                              Invoice No.:      A0001
Date: 24/10/2004
Sold to: ABC company
Item Quantity UnitPrice Amount
Pen 50 3 150
Book 100 5 500
Ruler 20 2 40
Total 690


Invoice No.: A0002
Date: 24/10/2004
Sold to: XYZ company
Item Quantity UnitPrice Amount
Pen 100 3 300
Book 120 5 600
Ruler 50 2 100
Total 1000
การทำ Normalization ของตัวอย่าง 5.3 (ได้รับคำแนะนำจาก อ.อมรทิพย์ rung@yonok.ac.th)
    การเริ่มต้นทำ normalization ต้องนำข้อมูลมาสร้าง ตารางเริ่มต้น ซึ่งเป็นขั้นตอนก่อนการทำ 1NF
    โดยไม่เขียน amount และ total เพราะเป็นค่าที่เกิดจากการคำนวณเท่านั้น
    ตาราง temp
    A0001,24/10/2004,ABC company,Pen,50,3
    A0001,24/10/2004,ABC company,Book,100,5
    A0001,24/10/2004,ABC company,Ruler,20,2
    A0002,24/10/2004,XYZ company,Pen,100,3
    A0002,24/10/2004,XYZ company,Book,120,5
    A0002,24/10/2004,XYZ company,Ruler,50,2

    การทำ 1NF ของ ตัวอย่าง 5.3
    นำตารางเริ่มต้นมาจัดการเรื่อง multivalue เช่น คนชอบกินหลายอย่าง หรือการเพิ่ม key ประกอบข้อมูลที่อาจซ้ำ
    ตัวอย่างนี้เพิ่มรหัสลูกค้า และรหัสสินค้า เป็น key เพราะคิดว่า ชื่อลูกค้า และชื่อสินค้า อาจมีโอกาสซ้ำกันได้ และไม่เหมาะที่จะเป็น key
    ตาราง tempoforder
    A0001,24/10/2004,101,ABC company,201,Pen,50,3
    A0001,24/10/2004,101,ABC company,202,Book,100,5
    A0001,24/10/2004,101,ABC company,203,Ruler,20,2
    A0002,24/10/2004,102,XYZ company,201,Pen,100,3
    A0002,24/10/2004,102,XYZ company,202,Book,120,5
    A0002,24/10/2004,102,XYZ company,203,Ruler,50,2
    การทำ 2NF ของ ตัวอย่าง 5.3
    แยกตาราง tempoforder เป็นหลายตาราง และทุกตารางมี primary key ที่มีการตรวจสอบการขึ้นตรงอย่างถูกต้อง
    primay key คือ รหัสใบสั่งซื้อ
    ตาราง invoid_1
    A0001,24/10/2004,101,ABC company
    A0002,24/10/2004,102,XYZ company
    primay key คือ รหัสใบสั่งซื้อ และรหัสสินค้า
    ตาราง invoid_2
    A0001,201,50,3
    A0001,202,100,5
    A0001,203,20,2
    A0002,201,100,3
    A0002,202,120,5
    A0002,203,50,2
    ตาราง product เพราะราคาขึ้นกับรหัสสินค้า
    primary key คือ รหัสสินค้า

    ตาราง product
    201,Pen,3
    202,Book,5
    203,Ruler,2

    การทำ 3NF ของ ตัวอย่าง 5.3
    ตาราง invoid_1 เพราะชื่อลูกค้าไม่ขึ้นกับรหัสใบสั่งซื้อ จึงต้องแยกไปทำตาราง customer
    primay key คือ รหัสใบสั่งซื้อ

    ตาราง invoid_1
    A0001,24/10/2004,101
    A0002,24/10/2004,102
    ตาราง customer เพราะชื่อลูกค้าไม่ขึ้นกับ รหัสใบสั่งซื้อ แต่ขึ้นกับรหัสลูกค้า
    primay key คือ รหัสลูกค้า

    ตาราง customer
    101,ABC company
    102,XYZ company
    primay key คือ รหัสใบสั่งซื้อ และรหัสสินค้า เพราะ ปริมาณ และราคาต้องขึ้นกับ key 2 ตัวนี้
    ตาราง invoid_2
    A0001,201,50,3
    A0001,202,100,5
    A0001,203,20,2
    A0002,201,100,3
    A0002,202,120,5
    A0002,203,50,2
    ตาราง product เพราะราคาขึ้นกับรหัสสินค้า
    primary key คือ รหัสสินค้า

    ตาราง product
    201,Pen,3
    202,Book,5
    203,Ruler,2

Relational Database Normalization 6/7

ขั้นตอนการ Normalization
    5.1 เปลี่ยนตารางที่ยังไม่เคย Normalization เป็น First Normal Form หรือ 1NF
    วิธีพิจารณา คือ แยกข้อมูลเป็นระเบียน โดยไม่มีการจัดกลุ่ม
    ตารางที่ไม่ผ่านการ normalization
    orderid
    305
    orderdate
    31/01/47
    productid
    432
    455
    467
    quan
    20
    2
    1
    ตารางที่ผ่านการ normalization ในระดับ 1NF
    orderid orderdate productid quan
    305 31/01/47 432 20
    305 31/01/47 455 2
    305 31/01/47 467 1


    5.2 เปลี่ยนจาก 1NF เป็น 2NF(Second Normal Form) คือการเปลี่ยนตารางที่มีปัญหา 4 ประการ
    วิธีพิจารณาเปลี่ยน 1NF เป็น 2NF คือ ไม่มี non key ตัวใด ไม่สัมพันธ์กับ primary key (ให้พิจารณาเฉพาะ non key และ primary key)
    สิ่งที่ได้จากตาราง 1 ตาราง จะแตกออกมาเป็นหลายตาราง
    5.2.1 แก้ไขข้อมูล ต้องแก้หลายระเบียน
    5.2.2 มีข้อมูลเดียวกันในหลายระเบียน อาจขัดแย้งกันได้
    5.2.3 การเพิ่มข้อมูลทำได้ยาก
    5.2.4 การลบข้อมูลทำได้ยาก
    ท่านลองพิจารณา Schema ของตารางนี้ว่าจะแยกได้กี่ตาราง
    จาก orderid,custid,custname,date,proid,proname,price,quantity,categoryid,categoryname
    เป็น orders (orderid,custid,custname,date,proid,proname,price,quantity)
    เป็น categories (categoryid,categoryname)
    เหตุที่แยก categories ออกมา เพราะ categoryid ไม่สัมพันธ์กับ orderid แต่สัมพันธ์กับ proid โดยตรง จึงต้องแยกออกมา

    5.3 เปลี่ยนจาก 2NF เป็น 3NF(Third Normal Form) คือแก้ปัญหายังไม่หมด อาจยังมีข้อมูลที่มีปัญหาอีก จึงต้องทำ 3NF
    วิธีพิจารณาเปลี่ยน 2NF เป็น 3NF คือ ไม่มี non key ตัวใด ขึ้นอยู่กับ non key ตัวอื่นใน entity เดียวกัน (ให้พิจารณาเฉพาะ non key และ non key)
    จาก orders (orderid,custid,custname,date,proid,proname,price,quantity)
    เป็น orders (orderid,custid,date)
    เป็น customers (custid,custname)
    เป็น order details (orderid,proid,price,quantity)
    เป็น products (proid,proname)

Relational Database Design 5/7

    4. ขั้นตอนการเขียน ER model

      4.1 กำหนด Entity type โดยกำหนดมาจากความต้องการของผู้ใช้ระบบ ว่าจะให้มี Entity สำหรับเก็บข้อมูลอะไรบ้าง

        เอนติตี้(Entity) อาจเรียกว่า file หรือ table
        4.1.1 Strong entity คือเกิดขึ้นด้วยตนเองไม่ขึ้นกับ entity ใด เช่น นักศึกษา หรืออาจารย์ หรือสินค้า เป็นต้น
        4.1.2 Weak entity คือขึ้นโดยอาศัย entity อื่น เช่น เกรดเฉลี่ย ที่มาจากแฟ้มผลการเรียน หรือ แฟ้มลงทะเบียน หรือ แฟ้มสั่งซื้อ เป็นต้น
        :: สิ่งต่าง ๆ ที่ผู้ใช้งานฐานข้อมูลจะต้องยุ่งเกี่ยวด้วย เช่น คน แผนก ประเภท การสั่งซื้อ เป็นต้น
        Entities are the principal data object about which information is to be collected. Entities are usually recognizable concepts, either concrete or abstract, such as person, places, things, or events which have relevance to the database. Some specific examples of entities are EMPLOYEES, PROJECTS, INVOICES. An entity is analogous to a table in the relational model.

      4.2 กำหนดความสัมพันธ์ (Relationship type) ที่เกิดขึ้นระหว่าง entity ในลักษณะของกริยา
        ดีกรีของความสัมพันธ์(Degree of relation) มี 4 แบบ
        4.2.1 Unary relationship คือความสัมพันธ์ภายใน entity เดียวกัน เช่นแต่งงานของพนักงาน แต่ถ้ามีระดับแบบลูกน้อง หัวหน้าจะเรียก Recursive relationship(Unary)
        4.2.2 Binary relationship คือความสัมพันธ์แบบสอง entity
        4.2.3 Ternary relationship คือความสัมพันธ์แบบสาม entity
        4.2.4 Quaternary relationship คือความสัมพันธ์แบบสี่ entity

      4.3 กำหนดแอททริบิวท์ (Attribute) ของแต่ละเอนติตี้
        :: แอททริบิวท์(Attibute) อาจเรียก field หรือ column คือ สิ่งที่ใช้อธิบายคุณสมบัติของเอนติตี้ เช่นคุณสมบัติของคน ก็มี รหัส ชื่อ อายุ เพศ เป็นต้น
        Attributes describe the entity of which they are associated. A particular instance of an attribute is a value. For example, "Jane R. Hathaway" is one value of the attribute Name. The domainof an attribute is the collection of all possible values an attribute can have. The domain of Name is a character string.
        A key is the attribute or set of attributes which allow to identify each unique instance of an entity. So no two instances of an entity have or ever can have the same key value. These keys are called candidate keys. (รหัสนักศึกษา กับรหัสบัตรประชาชน)
        Often we have different attributes or combinations of attributes which can serve as key. One key will be choosen and indicated as main key. It is called the primary key. The other keys are the alternate keys. The primary key is often the shortest possible and is the most unlikely to change.
        The primary key is indicated by underlining the name of attributes which form the primary key. In this case the attribute 'Code' has beed underlined.
        The roof, body and trim of a same car can have different colors. The attribute 'color' is called a multivalued attribute. This type of attribute is represented with a double line. (นักศึกษา 1 คนลงได้หลายวิชา)
        The 'age' attribute, indicated with the slashed line, is a derived attribute. It can be computed from the year and the present date. (เกรดเฉลี่ยของนักศึกษา)

        คำต่าง ๆ ที่ควรทราบ
        - คีย์หลัก (Primary key) :: คีย์หลักประจำแฟ้ม
            คุณสมบัติของคีย์หลัก
          1. ข้อมูลของแอททริบิวท์มีความเป็นหนึ่งเดียว(Uniqueness) กล่าวคือทุก ๆ แถวของตารางจะต้องไม่มีข้อมูลของแอททริบิวท์ที่เป็นคีย์หลักซ้ำกันเลย
          2. ต้องประกอบด้วยจำนวนแอททริบิวท์ที่น้อยที่สุด(Minimality) ที่จะสามารถใช้เจาะจง หรืออ้างอิงถึงแถวใดแถวหนึ่งในรีเลชันได้
        - คีย์คู่แข่ง (Candidate key) :: คีย์ที่สามารถเป็น Primary key ได้ เช่น รหัสบัตรประชาชน หรือรหัสผู้เสียภาษี
        - คีย์สำรอง (Alternate key) :: คีย์ตัวอื่น ๆ ในตารางหลังจากเลือก primary key แล้ว
        - คีย์นอก (Foreign key) :: คีย์ตัวอื่น ๆ ในตารางหลังจากเลือก primary key แล้ว
        - คีย์ร่วม (Composite key) :: สามารถแยกออกไปได้อีก เช่น ที่อยู่
        - Composite attibute :: สามารถแยกออกไปได้อีก เช่น ที่อยู่
        - Atomic attibute :: ไม่สามารถแยกออกไปได้อีก เช่น นามสกุล
        - Multivalued attibute :: อาจมีหลายค่าได้ เช่น สีรถ
        - Derived attibute :: ไม่มีค่าแน่นอนของตน แต่ขึ้นกับค่าอื่น เช่นอายุ ขึ้นกับปีเกิด และปีปัจจุบัน
        - Entity type :: ชื่อของ entity เช่น course (courseno,coursename)
        - Entity instance :: ค่าภายในของ entity เช่น bcom101,Introduction to computer

      4.4 คาร์ดินัลลิตี้ และปาร์ติซิเปชั่นของความสัมพันธ์ (Cardinality and participation of relationship)
        4.4.1 คาร์ดินัลลิตี้ของความสัมพันธ์(Cardinality of Relationship)
          :: แต่ละเอนติตี้มีความสัมพันธ์ต่อกัน โดยมีคำกริยามาเชื่อมระหว่างแต่ละเอนติตี้
        1. One-to-one relationship ความสัมพันธ์แบบ 1 ต่อ 1
          เช่น คนขับกับรถ หรือครูใหญ่กับโรงเรียน เป็นต้น
        2. One-to-many relationship ความสัมพันธ์แบบ 1 ต่อหลายข้อมูล
          เช่น ลูกค้ากับหมายเลขโทรศัพท์มือถือ หรือ อาจารย์ที่ปรึกษากับนักเรียน
        3. Many-to-many relationship ความสัมพันธ์แบบหลายข้อมูล ต่อหลายข้อมูล
          เช่น นักเรียนกับวิชาที่ลงทะเบียน หรือ คนงานกับโครงการสร้างบ้าน

        4.4.2 ปาร์ติซิเปชั่นของความสัมพันธ์ (Participation of relationship)
        :: ความสัมพันธ์ระหว่าง entity
        1. Total หรือ Mandatory participation (ต้องมี จะใช้เส้นคู่)
        2. Partial หรือ Optional participation (เลือกได้ จะใช้เส้นเดียว)

Relational Database ER Model 4/7

3. ER model (Entity-Relationship Model)
:: เสนอครั้งแรกโดย ปีเตอร์(Chen,1976 - 2519) เป็นเครื่องมือนำเสนอโครงสร้างของฐานข้อมูลใน ระดับความคิด(Conceptual level) ออกมาในลักษณะของแผนภาพ(Diagram) ที่ง่ายต่อความเข้าใจ เพื่อสื่อความหมายระหว่างนักออกแบบฐานข้อมูล และผู้ใช้ เกี่ยวกับ ความสัมพันธ์ของเอนติตี้(Entity) กับเอนติตี้(Entity) และเอนติตี้(Entity) กับ แอททริบิวท์(Attibute)
From: http://www.utexas.edu/cc/database/datamodeling/dm/erintro.html
The Entity-Relationship (ER) model was originally proposed by Peter in 1976 [Chen76] as a way to unify the network and relational database views. Simply stated the ER model is a conceptual data model that views the real world as entities and relationships. A basic component of the model is the Entity-Relationship diagram which is used to visually represents data objects. Since Chen wrote his paper the model has been extended and today it is commonly used for database design For the database designer, the utility of the ER model is:
- It maps well to the relational model. The constructs used in the ER model can easily be transformed into relational tables.
- It is simple and easy to understand with a minimum of training. Therefore, the model can be used by the database designer to communicate the design to the end user.
- In addition, the model can be used as a design plan by the database developer to implement a data model in a specific database management software.

From: http://itprojmngt.8m.net/softdev/analysis/erd/erd.html
The goal of Entity Relationship Modeling Technique is to discover and represent the relations between groups of information elements. The method will list the information which is essential for the application and/or organization, structure and describe this information. The results will serve to design the databases. The resulting drawing is never finished. It will evolve together with the information which is managed by the application or/and which serves the business purposes.

ส่วนประกอบของ ER model
- เอ็นติตี้ (Entity)
- แอททริบิวท์ (Attribute)
- ความสัมพันธ์ระหว่างเอ็นติตี้ (Relationship)
- ดีกรีของความสัมพันธ์ (Degree of a relation)

ขั้นตอนการเขียน ER model
3.1 สร้าง entity ขึ้นมาจากความต้องการของผู้ใช้
3.2 สร้างความสัมพันธ์(Relation) ระหว่าง entity
3.3 พิจารณา key ของแต่ละ entity
3.4 พิจารณาคุณสมบัติของ entity แต่ละตัว

Relational Database Design 3/7

2. ขั้นตอนเกี่ยวกับการออกแบบฐานข้อมูล
2.1 เปลี่ยนความต้องการของผู้ใช้เป็น ER model หรือ Relational model
2.1.1 โมเดลแบบ ER model (Entity-Relationship Model)
- เอ็นติตี้ (Entity)
- แอททริบิวท์ (Attribute)
- ความสัมพันธ์ระหว่างเอ็นติตี้ (Relationship)
- ดีกรีของความสัมพันธ์ (Degree of a relation)
2.1.2 โมเดลเชิงสัมพันธ์ (Relational model)
- รีเลชัน (Relation) หรือ Table หรือ file
- ทูเพิล (Tuple) หรือ Row หรือ Record
- แอททริบิวท์ (Attribute) หรือ Column หรือ Field
2.2 การทำนอร์มัลไลซ์ (Normalization)
2.3 กำหนดคุณสมบัติของเขตข้อมูลแต่ละตัว

Relational Databse Schema Example 2/7

ตัวอย่างของ Relation schema ของ Northwind
  1. Categories (CategoryID,CategoryName,Description,Picture)
  2. Customers (CustomerID,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax)
  3. Employees (EmployeeID,LastName,FirstName,Title,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,Extension,Photo,Notes,ReportsTo)
  4. Products (ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued)
  5. Shippers (ShipperID,CompanyName,Phone)
  6. Suppliers (SupplierID,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax,Homepage)
  7. Orders (OrderID,CustomerID,EmployeeID,OrderDate,RequiredDate,ShippedDate,ShipVia,Freight,ShipName,ShipAddress,ShipCity,ShipRegion,ShipPostalCode,ShipCountry)
  8. Order Details (OrderID,ProductID,UnitPrice,Quantity,Discount)

    ตารางข้างล่างนี้คือ ตารางแสดงความสัมพันธ์ที่ใช้โปรแกรม Microsoft access สร้างขึ้น

Relational Database Design 1/7

    สถาปัตยกรรมฐานข้อมูล(Database architecture) 3 ระดับ(Three-level architecture) ::
    1.1 ระดับภายนอก (External level)
      มาจากแบบฟอร์มเอกสาร ว่ามีอะไรในเอกสารบ้าง หรือจากผู้ใช้ที่แต่ละคน
      เป็นการรวบรวมข้อมูลอย่างง่าย ๆ จากผู้ใช้ เพื่อให้กับนักวิเคราะห์นำไปศึกษา
      ผู้ใช้คนที่หนึ่ง : (รหัส, ชื่อ)
      ผู้ใช้คนที่สอง : (รหัส, ที่อยู่)
    1.2 ระดับความคิด (Conceptual level)
      ตีความออกมาเป็นตารางโดยนำแบบฟอร์มต่าง ๆ มารวมกัน เพื่อแสดงความต้องการของผู้ใช้ในรูปที่สมบูรณ์
      อาจมีการวิเคราะห์ และออกแบบโดยผ่านขั้นตอนมากมาย ทั้ง E-R หรือ Normalization จนเสร็จสิ้น
      พนักงาน (รหัส, ชื่อ, ที่อยู่) ในแบบสคีมา(Schema)
      หรือ
      person (id, name, address) ในแบบสคีมา(Schema)
    1.3 ระดับภายใน (Internal level)
      ตีความในระดับการจัดเก็บข้อมูลจริง เป็นหน้าที่ของผู้ออกแบบอย่างแท้จริง
      struct person{
      int id;
      char name[20];
      char address[20]
      } index id;
    source : http://www.thaiall.com

Tuesday, December 2, 2008

วิธีแสดงภาษาไทย บน command prompt vista

<< การตั้งค่าให้ดอสพร็อมพ์ในวินโดวส์ 2000/XP/2003 ให้ใช้ภาษาไทยได้ >>
เขียนโดย คุณ ทัชชี่
โดยปกติแล้ว เราจะไม่สามารถใช้ภาษาไทยใน DOS BOX บนวินโดวส์ 2000 ขึ้นไป ไม่ได้เลย อ่านก็ไม่ได้ เขียนแล้วก็อ่านไม่รู้เรื่อง จะเปลี่ยนฟอนต์เป็นฟอนต์ที่มีภาษาไทยก็ไม่ได้อีก ดังนั้นมันต้องมีอะไรแน่ๆครับ

ผมเคยไปอ่านเจอวิธีแก้ปัญหานี้ใน Technet ของ Microsoft แต่มันเป็นวิธีแก้ปัญหาของคนในประเทศอื่นๆที่ไม่ได้มีลักษณะภาษาแบบภาษาไทย (ที่มันต้องมีสระบนสระล่างนี่แหล่ะครับ) ซึ่งลักษณะการแก้ปัญหาก็คล้ายๆกัน ผมจึงได้ลองประยุกต์ใช้ดู

ปกติเราจะเห็นดอสของวินโดวส์ 2000/XP หน้าตาเป็นแบบนี้



แล้วเราต้องการเปลี่ยนเป็นแบบนี้




ผมมี 2 ตัวเลือกให้คุณเลือก คือ
1) สำหรับมือใหม่
2) สำหรับมือเก่า


1. มือใหม่อ่านที่นี่ครับ ส่วนมือเก่า ข้ามไปอ่านหัวข้อถัดไปได้เลยครับ

1.1 ก่อนอื่นไปดาวน์โหลดไฟล์นี้มาก่อนครับ

http://www.thaikore.com/forum/index.php?act=attach&type=post&id=609

แล้วก็มาแตกไฟล์ (Unzip) จะเห็นได้ว่ามีไฟล์ทั้งหมด 4 ไฟล์ ตามภาพนะครับ



1.2 ให้ติดตั้งฟอนต์ Courier MonoThai ดังนี้

- คลิก Start >> Run แล้วพิมพ์ในช่องว่า fonts
- คลิกที่ไฟล์ courmon.ttf แล้วลากมาใส่โฟลเดอร์ fonts

1.3 ดับเบิลคลิกไฟล์ Registry ทั้ง 3 ไฟล์ เพื่อ Import เข้าไปใน Registry ของระบบ

1.4 Restart เครื่อง 1 ครั้ง

1.5 คลิก Start >> Programs >> Accessories >> Command Prompt แล้วคลิกตามภาพนี้



1.6 จากในภาพ ผมแนะนำให้ตั้งค่าขนาดฟอนต์เป็นขนาด 18 – 20 นะครับ เพื่อความคมชัด

1.7 หลังจากนั้นก็ลองใช้ดูได้เลยครับ


2. สำหรับมือเก่าอ่านตรงนี้ครับ

2.1 ดาวน์โหลดไฟล์ในข้อ 1.1 มานะครับ แล้วติดตั้งฟอนต์ให้เรียบร้อย

2.2 สั่งรันโปรแกรม regedit.exe แล้วเข้าไปแก้ไขในส่วนต่างๆ ดังนี้

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\Nls ให้เพิ่มข้อมูลชนิด String ชื่อ "0000041e"

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont ให้เพิ่มข้อมูลชนิด String ชื่อ "874" มีข้อมูลภายในคือ "Courier MonoThai"

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MS-DOS Emulation\Font ให้เปลี่ยนข้อมูลชนิด String ที่ชื่อ "font" ให้เป็น "Courier MonoThai"

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\DosKeybCodes ให้เพิ่มข้อมูลชนิด String ชื่อต่อไปนี้

"0000041E" มีข้อมูลภายในเป็น "th"

"0001041E" มีข้อมูลภายในเป็น "th"

"0002041E" มีข้อมูลภายในเป็น "th"

"0003041E" มีข้อมูลภายในเป็น "th"

2.3 สั่ง Restart เครื่อง 1 ครั้ง

2.4 เข้ามากำหนดค่าต่างๆตามรูป 1.5 ครับ

2.5 ทีนี้ก็จะสามารถใช้งานได้แล้วครับ

Tuesday, November 25, 2008

Config switch vtp mode

สวัสดีครับ เทอมนี้ได้เรียน datacom 2 เป็นเรื่องเครือข่าย โดยเฉพาะ Lab ได้ config siwtch , router....


เข้าเรื่องกันเลยดีกว่าครับ

สำหรับการทำ vtp บน switch การทดลองนี้ผมใช้ CCNA Network Visualizer
ก่อนอื่นก็ทำการเชื่อมต่อ switch และ host แล้วกำหนด IP ให้กับ host ดังรูป
ในการทดลองนี้ผมให้
vlan1 ip 127.2.145.0
vlan2 ip 192.2.146.0


เสร็จแล้วก็จะทำการ แบ่ง vlan บน switch ทั้งสองตัวกัน
โดยตัวแรก ก็จะมี 2 vlan ตัวที่ 2 ก็จะมี 2 vlan เช่นกัน
โดยใช้คำสั่งต่อไปนี้





switch Con0 is now available



Press RETURN to get started!



switch>enable
switch#vlan database
switch(vlan)#vlan 2 name VLAN1
VLAN 2 modified:
Name: VLAN1
switch(vlan)#vlan 2 name VLAN2
VLAN 2 modified:
Name: VLAN2
switch(vlan)#exit
APPLY completed.
Exiting....
switch#


ที่นี้ก็ลอง แสดง vlan ที่เราสร้างไว้




switch Con0 is now available



Press RETURN to get started!



switch>enable
switch#vlan database
switch(vlan)#vlan 2 name VLAN1
VLAN 2 modified:
Name: VLAN1
switch(vlan)#vlan 2 name VLAN2
VLAN 2 modified:
Name: VLAN2
switch(vlan)#end
^
% Invalid input detected at '^' marker.
switch(vlan)#exit
APPLY completed.
Exiting....
switch#config t
Enter configuration commands, one per line. End with CNTL/Z
switch(config)#vtp ?
domain Set the name of the VTP administrative domain.
file Configure IFS filesystem file where VTP configuration is stored.
interface Configure interface as the preferred source for the VTP IP updater
address.
mode Configure VTP device mode
password Set the password for the VTP administrative domain
pruning Set the adminstrative domain to permit pruning
version Set the adminstrative domain to VTP version

switch(config)#vtp ?
domain Set the name of the VTP administrative domain.
file Configure IFS filesystem file where VTP configuration is stored.
interface Configure interface as the preferred source for the VTP IP updater
address.
mode Configure VTP device mode
password Set the password for the VTP administrative domain
pruning Set the adminstrative domain to permit pruning
version Set the adminstrative domain to VTP version

switch(config)#vtp mode server
Device mode already VTP SERVER.
switch(config)#exit
switch#sh vlan

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2,Fa0/3, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12
2 VLAN2 active
3 vlan2 active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0

Remote SPAN VLANs
------------------------------------------------------------------------------


Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------


switch#

เพิ่ม port เข้าไปใน แต่ละ vlan


switch(config)#interface fastethernet 0/1
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 2
switch(config-if)#exit
switch(config)#interface fastethernet 0/2
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 2
switch(config-if)#exit
switch(config)#interface fastethernet 0/3
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 3
switch(config-if)#exit
switch(config)#interface fastethernet 0/4
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 3
switch(config-if)#exit
switch(config)#exit
switch#sh vlan

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
2 VLAN2 active Fa0/1, Fa0/2
3 vlan2 active Fa0/3, Fa0/4
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0

--More--

เสร็จแล้วก็ config ที่ switch ตัวที่ 2 ทำเหมือนกันกับตัวที่ 1

ต่อไปจะ config vpt



switch(config)#vtp mode server
Device mode already VTP SERVER.
switch(config)#vtp domain server1
Changing VTP domain name from NULL to server1
switch(config)#exit
switch#sh vtp status
VTP Version : 2
Configuration Revision : 4
Maximum VLANs supported locally : 64
Number of existing VLANs : 8
VTP Operating Mode : Server
VTP Domain Name : server1
VTP Pruning Mode : Disabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0x70 0x01 0xF2 0x72 0x97 0xA1 0x35 0xEB
Configuration last modified by: 0.0.0.0 at 11-29-93 20:39:24
Local updater ID is 0.0.0.0 on interface Vl1 (lowest numbered VLAN interface
found)
switch#

Friday, November 14, 2008

Remove element array in php




////////////////////////////////// Lists(Numerical Arrays) /////////////////////////////////

/**

* A small function to remove an element from a list(numerical array)

* Arguments: $arr - The array that should be edited

* $value - The value that should be deleted.

* Returns : The edited array

*/

function array_remove($arr,$value) {

return array_values(array_diff($arr,array($value)));

}



////////////////////////////////// Associative Arrays //////////////////////////////////////

/**

* This function will remove all the specified keys from an array and return the final array.

* Arguments : The first argument is the array that should be edited

* The arguments after the first argument is a list of keys that must be removed.

* Example : array_remove_key($arr,"one","two","three");

* Return : The function will return an array after deleting the said keys

*/

function array_remove_key() {

$args = func_get_args();

$arr = $args[0];

$keys = array_slice($args,1);



foreach($arr as $k=>$v) {

if(in_array($k, $keys))

unset($arr[$k]);

}

return $arr;

}



/**

* This function will remove all the specified values from an array and return the final array.

* Arguments : The first argument is the array that should be edited

* The arguments after the first argument is a list of values that must be removed.

* Example : array_remove_value($arr,"one","two","three");

* Return : The function will return an array after deleting the said values

*/

function array_remove_value() {

$args = func_get_args();

$arr = $args[0];

$values = array_slice($args,1);



foreach($arr as $k=>$v) {

if(in_array($v, $values))

unset($arr[$k]);

}

return $arr;

}

Sunday, October 26, 2008

Finding Duplicates with sql

SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

Tuesday, October 21, 2008

display ip on page


//"ip.php" example- display user IP address on any page
Header("content-type: application/x-javascript");
$serverIP=$_SERVER['REMOTE_ADDR'];
echo "document.write(\"Your IP address is: " . $serverIP . "\")";
?>

Wednesday, October 15, 2008

Change joomla template

Change joomla template

goto site>>template manager >> site template


Posted by Picasa
Posted by Picasa

Tuesday, October 14, 2008

XML super ster contest

More detail http://www.asean.xmlsuperstar.com/web/guest/home

่น่าสนใจครับ เปิดรับสมัครถึงวันที่ 28 February 2009 ก็จะมีหลายรายการที่จัดแข่งขันครับเข้าไปดูรายละเอียดได้

asiasoft.co.th

พอดีวันนี้ได้เข้าไปเจอเว็บหนึ่งชื่อว่า asiasoft.co.th ไปหน้าแรกเห็น product ของเขาเลยครับว่าเขาทำอะไรบ้าง เห็นเพื่อนมันเล่นเกมส์ ragnarok กันแต่ไม่รู้ว่าบริษัทไหนทำ พึ่งรู้ว่าเป็น asiasoft.co.th ก็วันนี้ละครับ

Gazopa picture search engine

วันนี้มารู้จัก web gazopa.com กันครับ

เป็นเว็บ search engine แต่เป็นเว็บ search เกี่ยวกับรูปภาพนะครับ
ลองเล่นดูแล้วจะรู้ว่ามันทำได้ยังไงวะ

http://www.gazopa.com/demo_video

Monday, October 13, 2008

Joomla class document

This is joomla class reference for version 1.0.xx

http://php.joomlademo.de/nav.html?_classes/index.html

Retrieving menu parameters joomla

I'm more or less a beginner developer in the Joomla world but have been writing code for the better part of my life. I've been looking through Google (honest, I've looked on *every page* it suggested.. or.. naah) and various forums, and components, and so on. After a while, I put the pieces together by studying source code and asking stupid questions here.

So, with that over dramatic intro, here's what I wanted to say:

[Q]
OK, I create parameters for my front-end component and populate them when I add a menu link to my component; how do I retrieve them *in* my component code?

[A]
$menu = new mosMenu( $database );
$menu->load( $Itemid );
$params = new mosParameters( $menu->params );

Saturday, October 11, 2008

CURL and Proxy Support

CURL has support for proxies, including SSL. Below we refer to the code snippet in the first example, but modify it to use a proxy.

[php] // Initialize the CURL library
$cURL = curl_init();

// Set the URL to execute
curl_setopt($cURL, CURLOPT_URL, "http://www.google.com");

// Set options
curl_setopt($cURL, CURLOPT_HEADER, 1);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cCURL, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($cCURL, CURLOPT_PROXY, "myproxy.com:1080");
curl_setopt($cCURL, CURLOPT_PROXYUSERPWD, "mysuername:mypassword");

// Execute, saving results in a variable
$strPage = curl_exec($cURL);

// Close CURL resource
curl_close($cURL);

// This will print out the HTML contents
echo($strPage);
?>[/php]


source : http://www.codeandcoffee.com

Drupal install error

วันนี้มีเวลาศึกษา cms อีกตัวว่าไปแล้วก็ลองศึกษามานานแล้วละ แกะ code ด้วย ตอนไปฝึกงานที่ CSI
แต่ตอนนั้นเล่นกับ drupal 5 วันนี้ลองเล่น drupal 6 บ้างมันจะเป็นยังไง
เริ่มแรกเลยผมก็ไปโหลดจาก drupal.org เป็น drupal 6 มาแล้วก็ up เข้า server ทันที แต่พอ install ปรากฏว่าเกิด error

Warning: fopen(./sites/default/default.settings.php) [function.fopen]: failed to open stream: No such file or directory in /home/www/virtual/morethailand.net/ednews/htdocs/includes/install.inc on line 188

Warning: Cannot modify header information - headers already sent by (output started at /home/www/virtual/morethailand.net/ednews/htdocs/includes/install.inc:188) in /home/www/virtual/morethailand.net/ednews/htdocs/includes/install.inc on line 618

Warning: Cannot modify header information - headers already sent by (output started at /home/www/virtual/morethailand.net/ednews/htdocs/includes/install.inc:188) in /home/www/virtual/morethailand.net/ednews/htdocs/includes/install.inc on line 619

ว่าไปแล้วความแตกต่างของขนาดไฟล์ drupal 5 กับ drupal 6 ก่างกันเยอะนะ drupal 5 สองร้อยกว่า ๆ แต่ drupal 6 ปาเข้าไป สี่ร้อยกว่า

error ยังไม่รู้เลยครับว่าจะแก้ยังไงดี

PHP MySQL Thai UTF8 TIS620

ทำความเข้าใจกับเครื่องหมาย
??????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????
เวลาดึงฐานข้อมูลจาก MySQL หรือ phpMyAdmin

ปัญหานี้เป็นปัญหาจริงหรือ
- ไม่ใช่ปัญหาแต่ว่าผู้ใช้ปรับตัวเข้ากับเวอร์ชั่นใหม่ไม่เป็น

ถ้าไม่ใช่ปัญหาแล้วจะทำยังไงกับ MySQL 5.x , 4.1.x ที่ไม่ยอมเป็นไทย
- เวลา Connect Database ให้เพิ่มในส่วนของ mysql_db_query($dbname,"SET NAMES tis620");
เพิ่มเข้าไปทุกครั้งมีมีการ Connect


ทำการเพิ่ม SET NAMES tis620 ไปแล้วแต่ phpMyAdmin เวลา Dump ข้อมูลมันก็ยังเป็น ????? อยู่อีก
- เปิด my.ini ขึ้นมาโดยกดที่ Start -> run พิมพ์ my.ini แล้วกด Enter
ในส่วนของ [client] ให้เพิ่ม

default-character-set = tis620
ในส่วนของ [mysqld] หลัง database directory ให้เพิ่ม
default-character-set = tis620
character-set-server = tis620
collation-server = tis620_thai_ci
init_connect = 'SET collation_connection = tis620_thai_ci'
init_connect = 'SET NAMES tis620'

จากนั้น Restart MySQL

แล้วคนใช้ UTF-8 จะทำยังไงในเมื่อเรา SET ทุกอย่างเป็น tis620 หมด
- คนใช้ UTF-8 ต้องมา mysql_db_query($dbname,"SET NAMES UTF8"); เองซะแล้ว !!
** ในการ Input ข้อมูลต่างๆใน phpMyAdmin นั้นจะไม่มีผลใดๆ กับผู้ใช้ UTF8

เมื่อก่อนไม่เห็นมีแบบนี้เลยแล้วเมื่อก่อนให้เลือก character set คืออะไร
- เมื่อก่อนเป็น Character Set แบบปลอมๆ คือข้อมูลต่างๆที่เก็บลงฐานข้อมูลมันคือ latin1 นั่นเอง
แล้วทำไม Latin1 มันใช้ภาษาไทยได้หละ แน่นอนอยู่แล้วมันใช้ได้เนื่องจาก latin1 มัน Key map แบบเดียวกะ keyboard ไทย
และประเทศอื่นๆ ก็เป็น Key Map เดียวกัน แต่สมัยนี้พวกภาษาจะไม่ขึ้นอยู่กับ Key Map ที่เราเห็นอยู่แล้ว (UTF-8)
*** และที่สำคัญในเวอร์ชั่น 4.0, 3.x มีให้เลือก character set ตรงนั้นไม่ได้มีความหมายว่า
เก็บข้อมูลเป็นภาษาไทย
ความหมายของมันคือ เรืยงลำดับภาษาไทย ต่างหาก คนไทยจึงเข้าใจผิดๆ มานาน -_-' กับ tis620 ใน MySQL
ไม่ก็ลองย้อนไปดูได้ครับแม้ว่าจะเลือก charset เป็น latin1 มันก็เก็บข้อภาษาไทยได้ เพียงแต่เรียงลำดับภาษาไทยไม่ได้เท่านั้น


แล้วทำไมสมัยนี้ MySQL ทำไมยุ่งยากกว่าเดิมเยอะ
- มันไม่ได้ยุ่งยากหรอกครับ มันอยู่ที่เราจะปรับตัวมากกว่า อย่ายึดติดกับหนังสือตามห้องสมุด เพราะที่ท่านอ่านมันเป็นความรู้เก่าๆ
ผมไม่ได้บอกว่าหนังสือที่เค้าขายกํนมันไม่ดีนะครับ เพียงแต่อยากจะบอกว่าที่เค้าขายกัน มันตกยุคไปนานโขแล้ว
เริ่มต้นทำความเข้าใจกับ MySQL ใหม่ เพราะที่มองเห็นว่ายุ่งยากกว่าเดิมจริงๆ ไม่ใช่ ควรเรียกว่าเป็นทางเลือกใหม่จะเหมาะสมกว่า
เพราะว่าระดับภาษาของ MySQL จะเจาะลึกลงไปเยอะมากคือ
- ต้องกำหนดภาษาเมื่อ Connect to Database
- ต้องกำหนดภาษาเมื่อ Create Database (การเรียงลำดับ)
- ต้องกำหนดภาษาเมื่อ Create Table (การเรียงลำดับ)
- ต้องกำหนดภาษาเมื่อ Create Field (การเรียงลำดับ)

รู้ปัญหามานานแล้วทำไมพึ่งมาบอก ??
- เพราะผมเลิกใช้ TIS-620 ไปแล้ว ตอนนี้ใช้แต่ UTF-8 ดีกว่าเยอะ !!

ความเสถียรของ MySQL 5.x เป็นยังไงบ้างเมื่อเทียบกับตัวเวอร์ชั่นเก่าๆ
- เสถียรกว่าเวอร์ชั่นเก่าๆ มาก ไม่มีอาการ Crash อิดๆ ออดๆ เหมือนแต่ก่อน ดังนั้น แนะนำให้ใช้เป็นอย่างยิ่ง

PHP5 ทำไมมี Bug เยอะจัง
- อันนี้ก็เข้าใจผิดๆ อีกเรื่องหนึ่งที่เจอกันเยอะมาก เข้าใหม่เสียว่า ที่ดูเป็น Bug ที่เห็นนั่นแหละ
คือเราเองเขียน Source Code ผิด เนื่องจาก PHP5 มี Sesnsitive มากๆ เกี่ยวกับการเขียน Code หลังจากที่
ผมเลือกใช้ PHP5 ผมจึงรู้ว่าสมองอันน้อยนิดที่คิดว่าผมเขียนโปรแกรมถูกนั้น ปรากฏว่าเจอ Error กระจาย
ต้องมาไล่แก้ code ใหม่อีกครั้ง ซึ่ง Error ที่แจ้งออกมา เราจะเห็นได้ว่าเราเขียนผิดเองจริงๆ และทำให้ผมมองย้อน
กลับไปที่ PHP4 จึงทำให้รู้ว่า PHP4 นี่แหละที่มี Bug เยอะกว่า PHP5เพราะว่าไม่ยอมแจ้งข้อผิดพลาดขึ้นมาเลย
ทั้งๆ ที่มีผิดอยู่เห็นๆ บทพิสูจน์นี้ทดสอบบน Domain ที่อยู่ใน Hosting ผมกว่า 60 กว่าโดเมนสามารถทำงาน
ได้กับ PHP5 ได้อย่างไม่มีปัญหาใดๆ เลยแม้แต่น้อย อีกทั้ง PHP5 ยังทำงานเร็วกว่า PHP4 เพราะเนื่องจากว่า PHP5
เลือกใช้ Zend Engine 2 นั่นเองจึงทำให้ความเร็วเพิ่มขึ้นมาประมาณ 20% และลด Load CPU ของ Server
ลงไปเยอะมาก

แล้วแบบนี้ก็ต้องหันมาใช้ PHP5 แทนที่ PHP4 ใช่ไหม ?
- อันนี้ขึ้นอยู่กับความชอบของแต่ละคน แต่ถ้าให้ผมแนะนำใช้เถอะครับ เพราะตอนนี้ PHP6 เค้าจะออกมากอีกแล้ว
แต่ว่าตอนนี้คุณยังไม่ได้เริ่มต้นที่จะทดลองใช้ PHP5 เลย ขืนใช้ PHP4 แล้ว Upgrade เป็น PHP6
ผมรับประกันได้เลยว่าคุณต้องปวดหัวแบบสุดๆ แน่นอน !! แล้วจะมาบอกอีกไม่ได้ว่า PHP5 และ PHP6 เค้ามี Bug !
ใช้ PHP4 แทนแล้วกัน ก็ขอยืนยันอีกครั้งว่า Source Code ของคุณจะเป็น Source Code รุ่นโบราณที่สุดในโลก

จาก http://www.appservnetwork.com

Wednesday, October 8, 2008

What ER design tools to you use?

Let us know what tools you use for your designs, and how you would rate them.

I have used DbDesigner4 http://fabforce.net/dbdesigner4/

and MySQL workbench (which is still in beta) http://forums.mysql.com/list.php?113

Dbdesigner4 is good but is no longer maintained, and is being replaced by MySQL workbench.

MySQL workbench is still in beta and still needs a fair bit of polish, but it looks promising.

Here are some other ER tools that I am aware of of:

- dbwrench (http://www.dbwrench.com/) Cross platform (JAVA)

- Microolap (http://microolap.com/) For windows only.

- SQL Manager (http://www.sqlmanager.net)

If you know of others, or would like to be listed, please make a post below.

Tuesday, October 7, 2008

Auto refesh page with meta refresh

some time you want to your webpage refesh every 10 second you can use meta refresh page

<meta equiv="refresh" content="10">

content is second to refresh.

Friday, September 19, 2008

Hex to int VS int to hex

public class Try
{
public static void main(String[] args)
{
System.out.println(Integer.toHexString(4500));
System.out.println(Integer.parseInt(Integer.toString(1194), 16));
}
};

Sunday, September 14, 2008

javascript remove array item



function removeVal(arr, valToRemove){
// Normalize to a string like !val!!val!!val!
var s = '!' + arr.join('!!') + '!';
// Remove targeted values with delimiters
s = s.replace(new RegExp('!' + valToRemove + '!', 'g'), '');
// Remove delimiter added to end in step 1
s = s.replace(/^!/, '');
// Remove delimiter added to start in step 1
s = s.replace(/!$/, '');
// Convert to array
return s.split('!!');
}

function test(){
var arr = [2,1,2,2,5,7,12,15,21,2]; // Check case with end vals
var s = arr.toString();
arr = removeVal(arr, 2)
alert(s + '\n' + arr.toString());
}




source : http://webdevel.blogspot.com

Saturday, September 13, 2008

javascript search string


<html>
<body>

<script type="text/javascript">

var str="Hello world!";

document.write(str.search("world") + "
");
document.write(str.search("World") + "
");
document.write(str.search("woorld") + "
");

</script>

</body>
</html>




If string for search certain in source in search string it return index of position

Friday, September 5, 2008

join

join function is easy to use concate string from array.

example

<php
$array = array('lastname', 'email', 'phone');
$comma_separated = join(",", $array);

echo
$comma_separated; // lastname,email,phone

?>


(php4, php5);

Tuesday, September 2, 2008

PHP Framework comparison

Framework PHP4 PHP5 MVC Multiple DB's ORM DB Objects Templates Caching Validation Ajax Auth Module Modules EDP
Akelos Akelos Support PHP4 Akelos Support PHP5 Akelos Support MVC Akelos Support Multiple DB Akelos Support ORM Akelos Support DB Objects Akelos Support Templates Akelos Support Caching Akelos Support Validation Akelos Support Ajax Akelos Support Auth Module Akelos Support Modules -
ash.MVC - ash.MVC Support PHP5 ash.MVC Support MVC - - ash.MVC Support DB Objects ash.MVC Support Templates - ash.MVC Support Validation - ash.MVC Support Auth Module ash.MVC Support Modules -
CakePHP CakePHP Support PHP4 CakePHP Support PHP5 CakePHP Support MVC CakePHP Support Multiple DB CakePHP Support ORM CakePHP Support DB Objects - CakePHP Support Caching CakePHP Support Validation CakePHP Support Ajax CakePHP Support Auth Module CakePHP Support Modules -
CodeIgniter CodeIgniter Support PHP4 CodeIgniter Support PHP5 CodeIgniter Support MVC CodeIgniter Support Multiple DB - CodeIgniter Support DB Objects CodeIgniter Support Templates CodeIgniter Support Caching CodeIgniter Support Validation - - - -
DIY - DIY Support PHP5 DIY Support MVC - DIY Support ORM DIY Support DB Objects DIY Support Templates DIY Support Caching - DIY Support Ajax - - -
eZ Components - eZ Components Support PHP5 - eZ Components Support Multiple DB - eZ Components Support DB Objects eZ Components Support Templates eZ Components Support Caching eZ Components Support Validation - - - -
Fusebox Fusebox Support PHP4 Fusebox Support PHP5 Fusebox Support MVC Fusebox Support Multiple DB - - - Fusebox Support Caching - Fusebox Support Ajax - Fusebox Support Modules -
PHP on TRAX - PHP on TRAX Support PHP5 PHP on TRAX Support MVC PHP on TRAX Support Multiple DB PHP on TRAX Support ORM PHP on TRAX Support DB Objects - - PHP on TRAX Support Validation PHP on TRAX Support Ajax - PHP on TRAX Support Modules -
PHPDevShell - PHPDevShell Support PHP5 - - - - PHPDevShell Support Templates - - PHPDevShell Support Ajax PHPDevShell Support Auth Module PHPDevShell Support Modules -
PhpOpenbiz - PhpOpenbiz Support PHP5 PhpOpenbiz Support MVC PhpOpenbiz Support Multiple DB PhpOpenbiz Support ORM PhpOpenbiz Support DB Objects PhpOpenbiz Support Templates - PhpOpenbiz Support Validation PhpOpenbiz Support Ajax PhpOpenbiz Support Auth Module - -
Prado
- Prado Support PHP5 Prado Support MVC Prado Support Multiple DB Prado Support ORM Prado Support DB Objects Prado Support Templates Prado Support Caching Prado Support Validation Prado Support Ajax Prado Support Auth Module Prado Support Modules Prado Support EDP
QPHP QPHP Support PHP4 QPHP Support PHP5 QPHP Support MVC QPHP Support Multiple DB - QPHP Support DB Objects QPHP Support Templates - QPHP Support Validation QPHP Support Ajax QPHP Support Auth Module QPHP Support Modules QPHP Support EDP
Seagull Seagull Support PHP4 Seagull Support PHP5 Seagull Support MVC Seagull Support Multiple DB Seagull Support ORM Seagull Support DB Objects Seagull Support Templates Seagull Support Caching Seagull Support Validation - Seagull Support Auth Module - -
Symfony Project - Symfony Project Support PHP5 Symfony Project Support MVC Symfony Project Support Multiple DB Symfony Project Support ORM Symfony Project Support DB Objects - Symfony Project Support Caching Symfony Project Support Validation Symfony Project Support Ajax Symfony Project Support Auth Module Symfony Project Support Modules -
WACT WACT Support PHP4 WACT Support PHP5 WACT Support MVC WACT Support Multiple DB - WACT Support DB Objects WACT Support Templates - WACT Support Validation - - WACT Support Modules -
WASP - WASP Support PHP5 WASP Support MVC - - WASP Support DB Objects WASP Support Templates - WASP Support Validation WASP Support Ajax WASP Support Auth Module WASP Support Modules -
Zend - Zend Support PHP5 Zend Support MVC Zend Support Multiple DB Zend Support ORM Zend Support DB Objects - Zend Support Caching Zend Support Validation - Zend Support Auth Module Zend Support Modules -
ZooP ZooP Support PHP4 ZooP Support PHP5 ZooP Support MVC ZooP Support Multiple DB - ZooP Support DB Objects ZooP Support Templates ZooP Support Caching ZooP Support Validation ZooP Support Ajax ZooP Support Auth Module - -

  • MVC: Indicates whether the framework comes with inbuilt support for a Model-View-Controller setup.
  • Multiple DB's: Indicates whether the framework supports multiple databases without having to change anything.
  • ORM: Indicates whether the framework supports an object-record mapper, usually an implementation of ActiveRecord.
  • DB Objects: Indicates whether the framework includes other database objects, like a TableGateWay.
  • Templates: Indicates whether the framework has an inbuilt template engine.
  • Caching: Indicates whether the framework includes a caching object or some way other way of caching.
  • Validation: Indicates whether the framework has an inbuilt validation or filtering component.
  • Ajax: Indicates whether the framework comes with inbuilt support for Ajax.
  • Auth Module: Indicates whether the framework has an inbuilt module for handling user authentication.
  • Modules: Indicates whether the framework has other modules, like an RSS feed parser, PDF module or anything else (useful).
  • EDP: Event Driven Programming.New!

source : http://www.phpframeworks.com/