MySQL view issue within PHP

2020-02-15 php mysql arrays view

Star Wars time AGAIN.

So, I have fixed code that wasn't working, but now it's behaving "strangely", IMO.

What the code is supposed to do is select characters from an MySQL table who don't use a lightsaber and then change their boolean flags from true to false. I know that the select code is working, I have tested in my SQL.

MySQL creation script for my person table...

name VARCHAR (80) not null unique, flag BOOLEAN, alias VARCHAR (20), 
species VARCHAR (20) not null, class VARCHAR (20) not null, gender ENUM ('male', 'female', 
'neither male nor female') NOT NULL, force_wielder BOOLEAN, 
pilot BOOLEAN, image VARCHAR (150) NOT NULL, quote VARCHAR (400)

Insert person code (with first character)

INSERT INTO person( name, flag, alias, species, class, gender, 
force_wielder, pilot, image, quote ) VALUES 
('Luke Skywalker', true, 'Commander', 'Human', 'Jedi', 'Male', true, true, 
'In 2014, Mark Hamill, the actor who plays Luke Skywalker has provided the voice of Darth Bane in 
Star Wars: The Clone Wars!'),

Code to select the characters (which works in MySQL)

$lightsaber = new lightsaber($Conn);
$gameView = new gameView($Conn);

if ($_POST) {
    if ($_POST['lightsaber'] = 1) {
        $lightsabers = $lightsaber->noLightsaberUsed();
        $smarty->assign('lightsabers_used', $lightsabers);
        for ($i = 0; $i <= count($lightsabers); $i++) {

    } elseif ($_POST['lightsaber'] = 2) {
        $lightsabers = $lightsaber->lightsaberUsed();
        $smarty->assign('lightsabers_used', $lightsabers);
        for ($i = 0; $i <= count($lightsabers); $i++) {

    $count = $gameView->countGameView();
    if ($count > 1) {
        header("Location: index.php?p=rebel");
    } elseif ($count < 1) {
        header("Location: index.php?p=fail");
    } else {
        header("Location: index.php?p=gameview");


Code to change the flags(in the gameview class)

    Public function iterateGameView($id)
        $changeFlag = "UPDATE gameview SET flag = false WHERE flag = :flag";
        $stmt = $this->Conn->prepare($changeFlag);
        $stmt->execute(array(':flag' => $id));

Select code (for clarity)

public function noLightsaberUsed()
        $query = "select * from person, weapon, person_weapon 
WHERE flag = 1 AND = person_weapon.person_id AND person_weapon.weapon_id = and != 'Lightsaber'
AND NOT IN (select from person, weapon, person_weapon WHERE = person_weapon.person_id
AND person_weapon.weapon_id = and = 'Lightsaber')";
        $stmt = $this->Conn->prepare($query);
        return $stmt->fetchAll(PDO::FETCH_ASSOC);


I'm at my wits end here and cannot for the life of me see why this isn't working.

I've been working on this for the better part of 2 days and I cannot see why it