Practice ... Form

Source: Internet
Author: User

Show data
Tables and classes correspond: Table names are class names, and column names are members of a class
Each piece of data in the table corresponds to the object that the class instantiates

Include ("Info.class.php");

$attr = Array ();

$info 1 = new Info ();
$info 1->code= "P001";
$info 1->name= "Zhang San";
$info 1->sex= "Male";
$info 1->nation= "Han";
$info 1->birthday = "1988-2-3";
Append elements to an array
Array_push ($attr, $info 1);

$info 2 = new Info ();
$info 2->code= "P002";
$info 2->name= "John Doe";
$info 2->sex= "female";
$info 2->nation= "Han";
$info 2->birthday = "1989-2-3";
Array_push ($attr, $info 2);

$info 3 = new Info ();
$info 3->code= "P003";
$info 3->name= "Harry";
$info 3->sex= "Male";
$info 3->nation= "Hui";
$info 3->birthday = "1990-2-3";
Array_push ($attr, $info 3);

echo "<table width= ' 100% ' border= ' 1 ' cellpadding= ' 0 ' cellspacing= ' 0 ' >";

echo "<tr><td> code </td><td> name </td><td> Gender </td><td> National </td> <td> birthday </td></tr> ";

foreach ($attr as $v)
{
echo "<tr><td>{$v->code}</td><td>{$v->name}</td><td>{$v->sex}</ td><td>{$v->nation}</td><td>{$v->birthday}</td></tr> ";
}

echo "</table>";

Class Info//info entity classes in a table
{
Public $code;
Public $name;
Public $sex;
Public $nation;
Public $birthday;
}

Practice ... Form

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.