1<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">2"http://www.w3.org/1999/xhtml">34<meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/>5<title> Untitled Document </title>67 8<body>9<?PHPTen$db =NewMysqli ("localhost","Root","3177389","My Test"); One!mysqli_connect_error () or Die ("Connection Failed"); A$sql ="SELECT * from Info"; -$result = $dbquery ($sql); -$attr = $resultFetch_all (); theEcho"<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>"; - for($i =0; $i <count ($attr); $i + +) -{$sex = $attr [$i] [2]?"male":"female"; +$name =shownation ($db, $attr [$i] [3]); -Echo"<tr><td>{$attr [$i][0]}</td><td>{$attr [$i][1]}</td><td>{$sex}</td ><td>{$name}</td><td>{$attr [$i][4]}</td></tr>"; + } A at - -Echo"</table>"; - function Shownation ($db, $code) - { - in$sqla ="Select Name from Nation where code= ' {$code} '"; -$resulta = $dbquery ($SQLA); to$jieguo = $resultaFetch_row (); + return$jieguo [0]; - the } *?> $</body>Panax NotoginsengPHP review-connect a database to make a table