Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dsn = 'mysql:dbname=testdb;host=127.0.0.1';
- $user = 'dbuser';
- $password = 'dbpass';
- try {
- $db = new PDO($dsn, $user, $password);
- } catch (PDOException $e) {
- echo 'Connection failed: ' . $e->getMessage();
- exit;
- }
- $sql = 'SELECT * FROM apartments';
- $apartments = $db->query($sql);
- // Render template.
- ob_start();
- include 'view/apartments/index.phtml';
- echo ob_get_clean();
- ?>
- <?php foreach ($apartments as $item) :?>
- <?php if ($item['free'] == 1) :?>
- <div style="display:inline">
- <? else: ?>
- <div style="display:none">
- <?php endif; ?>
- <!-- Place div content here -->
- </div>
- <?php endforeach; ?>
Add Comment
Please, Sign In to add comment