I can't show data of combobox use PDO

i make the combobox from database use PDO. Before it is success, but when i change its query is not working.

source code of combobox

<?php
	require_once 'app/config/session.php';
	require_once 'app/config/class.owner.php';

	$auth_owner	= new OWNER();

	$id_owner	= $_SESSION['user_session'];

	$stmt	= $auth_owner->runQuery("SELECT * FROM tbl_owner WHERE id_owner=:id_owner");
	$stmt->execute(array(":id_owner"=>$id_owner));

	$ownerRow=$stmt->fetch(PDO::FETCH_ASSOC);

	//for choosing the class by combobox
	$ops  = '';
	$stmt = $auth_owner->runQuery("SELECT 
										tbl_owner.id_owner,
										tbl_class.id_class, 
										tbl_class.class_name 
									FROM tbl_owner
										LEFT OUTER JOIN tbl_rooms ON tbl_owner.id_owner = tbl_rooms.id_owner
										LEFT OUTER JOIN tbl_class ON tbl_class.id_class = tbl_rooms.id_class
									WHERE tbl_owner.id_owner=$ownerRow[id_owner]");
	$stmt->execute();
	while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
		$ops .= "<option value=''>--Choise Class--</option>";
		$ops .= "<option value='" . $row['id_class'] . "'>" . $row['class_name'] . "</option>";
	}

	//Showing views
	include 'app/view/header.php';
	include 'app/view/owner/menu-owner.php';
	include 'app/view/owner/house-owner.php';
	include 'app/view/footer.php';
 ?>

and this source code of combobox

<div class="control-group form-group">
       <div class="controls">
             <label>Jenis Kelas:</label>
             <select name="id_class" class="form-control">
                     <?php echo $ops; ?>
             </select>
      </div>
</div>

Please help me

So it means that most likely your query failed. In order to fix your query you should see the error. I wrote a tutorial where described in detail how to report errors in PDO but in short all you need is to add the following line to your connection code

$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

fine, thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.