I can't figure out why this won't work. The database connects properly everything after the die staitment works if I remove it. I get a count value of '' for all 4 but if I manually execute the command
SELECT count(*) FROM `models` WHERE `fair` LIKE '%,C,%'
I get 260
as the result.
Here is my code.
<?php
require_once "includes/config.php";
// Create connection
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DATA);
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
//get list of fair options
$fairOptions=array(
"C"=>"Center of gravity centered",
"F"=>"Faces all same size",
"T"=>"Same relationship with all other faces",
"L"=>"Same friction on all faces"
);
$query="SELECT count(*) FROM `models` WHERE `fair` LIKE ?";
$stmt = $conn->stmt_init();
$stmt->prepare($query);
$stmt->bind_param('s',$test);
$stmt->bind_result($count);
foreach ($fairOptions as $key=>&$value) {
$test="%,?,%";
$stmt->execute();
echo $key . "=>" . $count . "<Br>";
$value="$value($count)";
}
die();