Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL: Update column items using the same webpage
    text
    copied!<p>I currently have a table in my database that has dozens of items. The PHP page I have now, labeled firstpage.php only displays 4 items from my database at a time, using LIMIT 4. I want to use the same page, firstpage.php, and have a button that says "Next," so when a user clicks that button, the next 4 items from my database are displayed until there are no more items. </p> <p><strong>Here is the code I have:</strong></p> <pre><code>&lt;?php require("database.php"); $start = (isset($_GET['start']) ? (int)$_GET['start'] : 0); $result = mysqli_query($con,"SELECT * FROM menuitem LIMIT $start, 4;"); if (!$result) { printf("Error: %s\n", mysqli_error($con)); exit(); } echo "&lt;table width='1024' border='0' cellpadding='10' cellspacing='5' align='center'&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; &lt;th&gt;Menu Items&lt;/th&gt; &lt;th&gt;Description&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;th&gt;Add to Order&lt;/th&gt; &lt;/tr&gt;"; while($row = mysqli_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td align='center'&gt;&lt;img src=\"" . $row['picturepath'] . "\" /&gt;&lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row['name'] . "&lt;/td&gt; &lt;td align='center'&gt; &lt;input type='button' value='More Info'; onclick=\"window.location='more_info.php?';\"&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row['price'] . "&lt;/td&gt; &lt;td align='center'&gt; &lt;input type='button' value='Add to Order' onclick=''&gt; &lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; mysqli_close($con); echo "&lt;table width=\"1024\" align=\"center\" &gt;"; echo "&lt;tr height=\"50\"&gt;&lt;/tr&gt;"; $next = $start + 4; echo '&lt;a href="?start="'.$next.'"&gt;Next items&lt;/a&gt;'; echo "&lt;/table&gt;"; ?&gt; </code></pre> <p><strong>So far, the "NEXT" link isn't loading the next 4 items. Don't know what I have wrong.</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload