I want to use the data of a mysql column inside an "if" but unfortunately I don't know how to do and I think i'm searching with the wrong terms.
So here is my code :
$reqcle=$bdd->prepare("SELECT * FROM clebeta WHERE cle='".$clebeta."'");
$reqcle->execute();
$countcle=$reqcle->rowCount();
$askcleutil=$reqcle->fetchAll();
//on vérifie d'abord que la clé existe en base de données
if($countcle == 1){
//on continue le traitement et on vérifie si la clé n'est pas déjà utilisée
if($askcleutil[2] == "0"){
//on continue le traitement et on vérifie l'existence du pseudo minecraft en base de données
} else {
//on affiche que la clé est déjà utilisée
}
} else {
//on affiche une erreur : clé inexistante
}
It's in my last if : if($askcleutil[2] == "0")
I want to test the value of the 'active' column inside my DB but I don't know how to do
Sorry if i'm not clear but I don't know how to explain this clearly
You use selectAll()
, so you miss your loop.
Returns an array containing all of the result set rows (http://php.net/manual/en/pdostatement.fetchall.php)
You need like this:
foreach ($askcleutil as $row) {
if ($row['a_col_name_of_your_selected_row'] == 0) {
// Handle
}
}