<?php $mysqli=new mysqli('localhost','root','','tamia'); $mysqli->set_charset('utf8'); if($mysqli->connect_errno){ die('CONNECT ERROR:'.$mysqli->connect_error); } $sql="SELECT id,usernam,age FROM users"; $mysqli_result=$mysqli->query($sql); if($mysqli_result && $mysqli_result->num_rows>0){ while($row=$mysqli_result->fetch_assoc()){ $rows[]=$row; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document</title> </head> <body> <h2></h2> <table border="1" cellpadding="0" cellspacing="0" width="80%" bgcolor="#ABCDEF"> <tr> <td>编号</td> <td>用户名</td> <td>年龄</td> </tr> <<?php $i=1 foreach($rows as $row):?> <tr> <td><?php echo $i;?></td> <td><?php echo $row['username'];?></td> <td><?php echo $row['age'];?></td> </tr> <?php endforeach?> </table> </body> </html>
按照老师的些的,提示29行语法错误哇,
eeerrr