//此行报错:syntax error, unexpected '",3"' 语法错误。 $sql = "SELECT * FROM message limit".($page-1)*3.",3"; //然后加两个变量,再写成$sql = "SELECT * FROM message limit $page_from,$page_size";就没问题了 $res = $conn->query($sql); while($abc = $res->fetch_assoc()){ $rows[] = $abc; }
<table border="1" style="text-align:center; width:200px;"> <tr> <th>内容</th> </tr> <?php foreach ($rows as $abc): ?> <tr> <td><?php echo $abc['mes']; ?></td> </tr> <?php endforeach ?> </table>
$sql
=
"SELECT * FROM message limit"
.(
$page
-1)*3.
",3"
;这里的limit后面应该要有空格
$sql
=
"SELECT * FROM message limit "
.(
$page
-1)*3.
",3"
;