Intereting Posts
Драйвер sqlsrv не появляется на сервере WAMP phphinfo () после добавления записей расширения в файле php.ini Ошибка компиляции: элементы сопоставления POSIX не поддерживаются Как отправить запрос приложения Facebook для получения данных о принятии? Как я могу очистить содержимое веб-сайта на PHP с веб-сайта, для которого требуется вход в cookie? Чтение данных в последовательном порту на окнах с php Some Hosting Not Liking SET NAMES utf8 – «Невозможно выполнить запросы, в то время как другие небуферизованные запросы активны». Исключительно простые PHP и Mysql Как заменить несколько элементов из текстовой строки в PHP? Обратный скошенный массив к многомерному Yii – удалить 'index' из URL Функция PHP strtotime () неверна на 1 час? Форма PHP отправляет электронную почту нескольким получателям Загрузка файла с другим именем в сохраненное имя категории wp-запроса и имеет тег Как извлечь данные из определенного массива PHP

PHP-код не будет выводить информацию о базе данных

Моя текущая программа по какой-то причине не будет регистрировать мои значения базы данных, даже если мой предыдущий код ( выглядит идентично, но из разных таблиц базы данных ) работает просто отлично.

Пока у меня нет ошибок при запуске. Единственное, что печатает для каждой страницы, – это заголовок таблицы. Также клиентская страница работает отлично. Таким образом, моя текущая проблема – продукт (tv, cell, computer) и страница транзакций.

Мой текущий файл index.php (основная программа) выглядит следующим образом:

<?php //url /index.php?action=clients include('header.php'); // create top box include('sidemenu.php'); // create side menu //database connection include('pdo_connect.php'); //Read data type $type = ""; if (isset($_REQUEST['action'])) $type = $_REQUEST['action']; //echo 'Action: {$type}'; switch($type) { case 'products' : //display a list of clients //define sql $sql = "SELECT product_type, product_title, product_description, unit_price FROM products WHERE product_type = :product_type"; $values = array(':product_type'=>$_GET['product_type']); $products = getAll($sql); //display result displayProductList($products); break; case 'clients' : //displaya list of movies $sql = "SELECT first_name, last_name, email FROM p_clients"; $clients = getAll($sql); displayClientList($clients); break; case 'transactions' : $sql = "SELECT products.product_title, products.product_description, products.unit_price, p_clients.first_name, p_clients.last_name, sales.quantity FROM p_clients INNER JOIN sales, products ON p_clients.client_id = sales.client_id AND products.product_id = sales.product_id"; $transactions = getAll($sql); displayTransactionList($transactions); break; default: defaultView(); break; } include('footer.php'); function defaultView() { ?> <!-- add page content --> <div id='content'> <h2>Welcome to our movie store</h2> </div> <div id = 'image'></div> <div id = 'box'> <p id = 'text-box'> We appreciate your interest in our products and services. Please reference the the links provided to see our current specials for each of our clients. </p> </div> <?php } function displayProductList($products) { echo "<div id='content'> <h2>List of Products</h2>"; echo "<table id = clients>"; echo "<tr><td id = 'title'>Product Name</td><td id= 'title'>Description</td><td id = 'title'>Cost</td></tr>"; //display each record for ($i = 0; $i < count($products); $i++){ echo "<tr><td>{$products[$i]['product_title']} </td><td> {$products[$i]['product_description']} </td><td> {$products[$i]['unit_price']} </td></tr>" ; } echo "</table>"; echo "</div>"; } function displayClientList($clients) { echo "<div id='content'> <h2>List of Clients</h2>"; echo "<table id = 'long'>"; // echo "<table>"; echo "<tr><td id = 'title'>First Name</td><td id= 'title'>Last Name</td><td id = 'title'>Email</td></tr>"; //display each record for ($i = 0; $i < count($clients); $i++){ echo "<tr><td>{$clients[$i]['first_name']}</td><td> {$clients[$i]['last_name']} </td><td> {$clients[$i]['email']} </td></tr>"; } echo "</table>"; echo "</div>"; } function displayTransactionList($transactions) { echo "<div id='content'> <h2>List of Client Transactions</h2>"; echo "<table id = 'long'>"; // echo "<table>"; echo "<tr><td id = 'title'>First Name</td><td id= 'title'>Last Name</td><td id = 'title'>Product Title</td> <td id = 'title'>Product Description</td><td id = 'title'>Cost</td><td id = 'title'>Quantity</td></tr>"; //display each record for ($i = 0; $i < count($transactions); $i++){ echo "<tr><td>{$transactions[$i]['first_name']}</td><td> {$transactions[$i]['last_name']} </td><td> {$transactions[$i]['product_title']} </td><td> {$transactions[$i]['product_description']} </td><td> {$transactions[$i]['unit_price']} </td><td> {$transactions[$i]['quantity']} </td></tr>"; } echo "</table>"; echo "</div>"; } function getAll($sql, $values =null){ global $db; $statm = $db->prepare($sql); //Method 4 //assign a value to named parameters using an array //$values= array(':genre'=>'drama'); $statm->execute($values); //Fetch all records $result = $statm->fetchAll(); return $result; } 

Файл sidemenu.php вызывает каждый из ссылок:

 <div id = 'sidebar'> <h4>Links</h4> <ul id = "nav" class= "text-left"> <li><a href='index.php'>Home</a></li> <li><a href='index.php?action=products&product_type=tv'>TV Products</a></li> <li><a href='index.php?action=products&product_type=cell'>Cell Phone Products</a></li> <li><a href='index.php?action=products&product_type=computer'>Computer Products</a></li> <li><a href='index.php?action=clients'>List of Customers</a></li> <li><a href='index.php?action=transactions'>List of Transactions</a></li> <!--<li><a href='index.php?action=moviesFS&genre=sci-fi&date_out=2009-12-15'>List of Favorite Sci-Fi Movies</a></li>--> </ul> </div> 

Как вы можете видеть, если я ввожу свой sql в свою базу данных, он работает нормально:

введите описание изображения здесь