Goal: To display a category select-box and its corresponding subcategory select-box. MySQL table is set up to have id(primary key), master_id(referencing on the primary key) and name. I set 4 error code blocks and after debugging i keep getting “error 2:true”. Thus, displaying a category but no subcategory. How come i keep getting this error? Is there something missing?
PHP comparing category&value to display on the subcategory selectbox
if (!empty($_GET['id']) && !empty($_GET['value'])) {
$id = $_GET['id'];
$value = $_GET['value'];
try {
$objDb = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass);
$sql = "SELECT * FROM `categories` WHERE `master_id`=?";
$statement = $objDb->prepare($sql);
$statement->execute(array($value));
$list = $statement->fetchAll(PDO::FETCH_ASSOC);
}
?>
You say
master_idin your question but you havemasterin your query.