Php 从MySQL中提取数据并在页面之间拆分

Php 从MySQL中提取数据并在页面之间拆分,php,mysql,if-statement,Php,Mysql,If Statement,我的工作代码从我的数据库中引入数据,如下所示: require("database.php"); $result = mysqli_query($con,"SELECT * FROM menuitem"); echo "<table width='1024' border='0' cellpadding='10' cellspacing='5' align='center'> <tr> <th></th> <th>M

我的工作代码从我的数据库中引入数据,如下所示:

require("database.php");

$result = mysqli_query($con,"SELECT * FROM menuitem");

echo "<table width='1024' border='0' cellpadding='10' cellspacing='5' align='center'>
<tr>
    <th></th>
    <th>Menu Items</th>
    <th>Description</th>
    <th>Price</th>
    <th>Add to Order</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    echo "<td align='center'><img src=\"" . $row['picturepath'] . "\" /></td>";
    echo "<td align='center'>" . $row['name'] . "</td> <td align='center'> <input type='button' value='More Info'; onclick=\"window.location='more_info.php?';\"> </td>";
    echo "<td align='center'>" . $row['price'] . "</td> <td align='center'> <input type='button' value='Add to Order' onclick=''> </td>";
    echo "</tr>";
}
echo "</table>";

mysqli_close($con);
require(“database.php”);
$result=mysqli_查询($con,“从菜单项中选择*);
回声“
菜单项
描述
价格
增加订单
";
while($row=mysqli\u fetch\u数组($result)){
回声“;
回声“;
回显“$row['name']”;
回显“$row['price']”;
回声“;
}
回声“;
mysqli_close($con);
但是,我调用的专栏有20多个条目。我想将页面显示的项目数量限制为每页4个项目,然后创建多个页面,列出数据库中剩余的项目

到目前为止,我已经尝试在if-then语句中添加,但效果不是很好。我不确定这是否是正确的方法

SELECT * FROM menuitem LIMIT $startPositionVariable,$howManyItemsPerPageVariable
一个单独的查询应该确定有多少个条目开始,并相应地确定有多少页