Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Coding Help

Featured Replies

Hi there, i want pagination on a project i am working on. I have generated code to display results from database, but not sure on how to paginate. Could you please help me?

 

Here is my code to generate it:

 

<?php

// Run a select query to get my letest 6 items

// Connect to the MySQL database

include "storescripts/connect_to_mysql.php";

$dynamicList = "";

$sql = mysql_query("SELECT * FROM products WHERE category='darts' ORDER BY date_added DESC");

 

$productCount = mysql_num_rows($sql); // count the output amount

 

if ($productCount > 0) {

while($row = mysql_fetch_array($sql)){

$id = $row["id"];

$product_name = $row["product_name"];

$price = $row["price"];

$details = $row ["details"];

$category = $row["category"];

$subcategory = $row["subcategory"];

$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));

$dynamicList .= '<div class="contentbox">

<a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a>

<div class="contenttype">

<h2>' . $product_name . '</h2>

<p>Our Price:£'.$price.'</p>

<div id="CollapsiblePanel1" class="CollapsiblePanel">

<div class="CollapsiblePanelTab" tabindex="0"><a href="product.php?id=' . $id . '"><u>More Info</u></a></div>

<div class="CollapsiblePanelContent">

</div>

</div>

</div>

<br class="clear_both" />

</div>';

}

} else {

$dynamicList = "We have no products listed in our store yet";

}

mysql_close();

?>

You will need to store what page the user is currently on using either session vars or url params.

 

Stackoverflow.com is probably the site you want to check out for this sort of thing.

 

Personally I find using a CMS (large pre-built application on a server for managing content) a better route for all projects, rather than building basic but tricky functionality like pagination yourself.

 

If you have time, perhaps look at Silverstripe, a great current CMS.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.