Skip to content

Instantly share code, notes, and snippets.

@hechien
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save hechien/203c8cac7f340372e838 to your computer and use it in GitHub Desktop.

Select an option

Save hechien/203c8cac7f340372e838 to your computer and use it in GitHub Desktop.
<?php
$sql = "SELECT * FROM `call`";
$result = mysql_query($sql);
?>
<table>
<tbody>
<?php
while(($record = mysql_fetch_assoc($result))){
?>
<tr>
<td><?php echo $record["id"]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
$limit = 5;
$offset = intval($_GET["page"]) * $limit + 1;
$sql = "SELECT * FROM shop LIMIT $limit OFFSET $offset";
$total_pages = (mysql_num_result($result) / $limit) + 1;
for($i = 1; $i <= $total_pages; $i++){
<a href="call.php?page=$i">第 $i 頁</a>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment