Pergunta

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?

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top