I am able to grab the current poll_id fine and get it to echo out the correct value.
I'm also trying to echo the value from the next row in the table at the moment just the number but it's so I can insert a link to the next poll.
I keep getting the Next Poll Not Available, although I know that there is a "next" poll.
What am I doing wrong?
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT poll_id, poll_question FROM poll_main LIMIT 5, 1";
$nxt = "SELECT poll_id FROM poll_main WHERE ID > ? LIMIT 1";
$result = $conn->query($sql);
$nxtres = $conn->query($nxt);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<input type='hidden' id='poll_id' value='" . $row["poll_id"]. "'/>";
}
} else {
echo "Current Poll Not Available";
}
if ($nxtres->num_rows > 0) {
while($row = $nextres->fetch_assoc()) {
echo $row["poll_id"];
}
} else {
echo "Next Poll Not Available";
}
$conn->close();