0

Hello, I have my php script using this code:

$start = (isset($_GET['start']) ? (int)$_GET['start'] : 0);

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

This pulls in the data from my database fine. Now I want to load the next 4 items from my database when a user clicks the "Next items" link, so I put this in my code:

echo "<table width=\"1024\" align=\"center\" >";
echo "<tr height=\"50\"></tr>";

$next = $start + 4;
echo '<a href="?start="'.$next.'">Next items</a>';

echo "</table>";

Clicking the "Next items" link loads the url firstpage.php?start= but it doesn't load the next four items. Anyone see what i'm doing wrong?

2
  • 1
    There is a " too many in your HTML output. Commented Dec 4, 2013 at 17:57
  • Thank you! My eyes literally kept ignoring those quotes until you guys pointed it out. Thanks. Upvote for you! Commented Dec 4, 2013 at 18:02

1 Answer 1

3

You're using the wrong combination of quotes when outputting the link:

echo '<a href="?start=' . $next . '">Next items</a>';
// unneeded double quote before your $next variable
Sign up to request clarification or add additional context in comments.

1 Comment

AH! Dang it. That was it! You're the best! Thank you! I'll accept this in a few minutes when allowed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.