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