Reputation:
I have not found anything useful about it on the internet and I have been trying for 5 days. I'm learning PHP on my own and trying to make some nice projects to bring to school. I have two buttons in my project: one to go back and the other to go forward into MySQL records. My code doesn't work and I don't know why. I think the problem is with the $w array in PHP code. **
I've found the $id variable's never incremented by 1 as I'd like, where is the problem?
** is there a way of not storing data momentarily in an array?
<form action="prova.php">
<input type="submit" class="button" name="indietro" value="<"/>
<input type="submit" class="button" name="avanti" value=">"/></form>
<?php
$id = 0;
$db_host = "localhost";
$db_username = "root";
$db_password = "";
$connection = mysqli_connect($db_host, $db_username, $db_password);
$db = mysqli_select_db($connection, "cherubini");
$sql = mysqli_query($connection, "SELECT * FROM cherubini WHERE ID = $id+1 LIMIT 1;");
$w = array(200000);
while($row = mysqli_fetch_array($sql)) {
$w = $row['Lemma'];
}
if ($_GET) {
if (isset($_GET['indietro'])) {
} elseif (isset($_GET['avanti'])) {
$sql = mysqli_query($connection, "SELECT * FROM cherubini WHERE ID = $id = $id + 1;");
$w = array(200000);
while($row = mysqli_fetch_array($sql)) {
$w = $row['Lemma'];
}
echo ($w);
}
}
?>
Upvotes: 0
Views: 234
Reputation: 765
1.You can use data table js and css. May be useful for you.
2.You have to use LIMIT
statement for get data.(pagination).
LikeLIMIT 1,1
Upvotes: 1