Data on the condition is not displayed. No conditions are displayed. Here is the database and table.
-- создание базы в том случае, если ее нет CREATE DATABASE IF NOT EXISTS abc; -- сделать базу текущей USE abc; -- создание таблицы в том случае, если ее нет CREATE TABLE IF NOT EXISTS t1( id SERIAL, start VARCHAR(50) comment 'начало акции', end VARCHAR(50) comment 'конец акции', name VARCHAR(250) NOT NULL comment 'название товара или услуги', price DECIMAL(15, 2) NOT NULL comment 'обычная цена', price_action DECIMAL(15, 2) NOT NULL comment ' акционная цена', discount INT comment 'скидка', PRIMARY KEY(id) ); Here is the entire PHP file
<?php header("Content-Type: text/html; charset=utf-8"); mysql_set_charset('utf8'); ?> <!DOCTYPE html> <html> <head> <title></title> <script src="script/jquery-1.11.3.min.js"></script> <style> ol, ul { list-style: none; } table { border-collapse: collapse; border-spacing: 0; } table { height: auto; width: 1000px; float: left; margin: 20px auto; } table th, td { width: 166.66px; padding: 2px 2px 2px 2px; font-size: 16px; text-align: center; background-color: #dbe8f0; border: 1px solid #6897bb; } </style> </head> <?php /*ФОРМА 4*/ /*===ПОИСК ДАННЫХ В БАЗЕ===*/ if($_REQUEST['find']) { function funFind() { //ключевое слово для поиска $word = $_POST['serch']; //открытие соединения с сервером базы данных (SQL сервер, SQL логин, SQL пароль) $connect = mysql_connect('localhost', 'root', '12345'); //выбор базы данных (база SQL, переменная соединения) mysql_select_db('abc', $connect); //запрос $query = "SELECT start, end, name, price, price_action, discount FROM t1"; //$query = "SELECT start, end, name, price, price_action, discount FROM t1 WHERE = 5"; //выполнение запроса и запись выполнения в переменную $run = mysql_query($query, $connect); //результат - массив $result = mysql_fetch_array($run) or die(mysql_error()); echo '<table><tr><th>начало акции</th><th>конец акции</th><th>название</th><th>обычная цена</th><th>акционная цена</th><th>скидка в %</th></tr>'; do{ echo '<tr>'; echo '<td>'.$result[0].'</td>'; echo '<td>'.$result[1].'</td>'; echo '<td>'.$result[2].'</td>'; echo '<td>'.$result[3].'</td>'; echo '<td>'.$result[4].'</td>'; echo '<td>'.$result[5].'</td>'; echo '</tr>'; } while($result = mysql_fetch_array($run)); echo '</table>'; //закрытие соединения mysql_close($connect); //отмена повторной отправки формы header("Location: ".$_SERVER["REQUEST_URI"]); exit; } } ?> <body> <form id="f4" name="form4" action="" method="post"></form> <input type="text" form="f4" name="serch" /> <input type="submit" form="f4" name="find" value="Искать данные" /> <br /> <br /> <?php funFind(); ?> </body> </html> This request is working.
$query = "SELECT start, end, name, price, price_action, discount FROM t1"; This request (it is for comment) does not work anymore !!!
$query = "SELECT start, end, name, price, price_action, discount FROM t1 WHERE = 5"; A query with input through the input field does not work either.
$query = "SELECT start, end, name, price, price_action, discount FROM t1 WHERE id = ".(int)$word.""; What am I doing wrong? Tell me.
WHERE = 5but there should be at leastWHERE id = 5- Alexey ShimanskyWHERE id = 5, data is not output - Anton