H
H
hello world2015-11-02 20:34:46
PHP
hello world, 2015-11-02 20:34:46

Why am I not receiving information?

Good evening everyone.
There is index.php, which displays full information about the hotel.

<?php foreach ($hotel as $id => $hotel): ?>
// перечисление полей вывода
<a href="details?id=<?=$hotel['id']?>"><?=$hotel['name']?></a>
<?php endforeach; ?>
//Вывожу через запрос:
$query = 'SELECT * FROM hotel';
 $stmt = $pdo->prepare($query);
 $stmt->execute();
 $hotel= $stmt->fetchAll();

As you noticed, there is a link to the details.php document (removed the extension via htaccess), which should display full information about the hotel (address, description, etc.). BUT!! I created a page, wrote a query like this:
$id = $_GET['id'];
  $stmt = $pdo->prepare('SELECT * FROM hotel WHERE id = :id');
  $details = $stmt->execute(array(':id' => $_GET['id']));

As a result, nothing is displayed on the page. Wrote to check Nothing outputs. In the address bar details?id=1 etc. Tell me what am I doing wrong? Recently switched to PDO
Проверка - <?=$details['id']?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-11-02
@hello

<?php foreach ($hotel as $id => $hotel): ?>
The $hotel variable is overridden. Give her another name, at least:
Also after:
You need to do fetch / fetchAll, etc. Since the data has not yet been received.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question