I want to have a row with a column called: 'seen', then this column will have either a default of no value or a 'yes' value.
So..
- Grab one row where it hasn't been 'seen' before.
- Update the above row 'seen column' to say 'yes'.
- If all rows have the value of 'yes' then a notice/error displays: You have successfully completed all numbers.
I've tried the best I can do achieve it, but it's not working. I think my logic in tackling this may be incorrect?
include 'DB.php';
$con = mysqli_connect($host,$user,$pass);
$dbs = mysqli_select_db($databaseName, $con);
// Grabs one row where it hasn't been seen before
$query = mysqli_query("SELECT number, association, image_file, skeleton, sound, colour, comments FROM num_image WHERE seen='' ORDER by rand() LIMIT 1");
// Updates the above row with the 'seen' column saying 'yes''
$query = mysqli_query("UPDATE num_image SET seen = yes");
// Fetches Result
$thestuff = mysqli_fetch_row($query);
$seenme=$_POST['seen']; // get value of 'seen' column
$result = mysqli_query("SELECT * FROM num_image where seen=$seenme");
// Trying to delivery a message if the enitre 'seen' column is ALL yes.
while($row = mysqli_fetch_row($result))
{
if($row['seen'] == 'yes')
{ // All numbers seen
echo 'You have successfully completed all numbers.';
echo json_encode($thestuff);
}
else
{ // Show numbers
echo json_encode($thestuff);
}
}
Does the SELECT and UPDATE row also have to be an if statement? Cheers