PHP results are not displayed and no error message

A beginner tutorial here is looking for advice ...

I have a very simple PHP query for a MySQL database, which is supposed to create a drop down menu populated with information from a MySQL database. I was wondering if, based on the code included in this post, someone could point me in the right direction or give me a suggestion on what I should do.

Ps MySQL database - these are the products that I select from the inside - these are the products, and the column that I am trying to select is the description.

<?php
$adConn = mysqli_connect("localhost", "user", "password", "products");

$result = "SELECT * FROM products where Description order by descending";
$result = mysqli_query($adConn, $result);

echo "<select name='product'>";
while ($row = mysql_fetch_array($result))
{
    echo "<option value='" . $row['Description'] . "'>" . $row['Description'] . "</option>";
}
echo "</select>";

?>
+4
source share
4 answers

Invalid condition where. Also find order by.

Try the following:

$result = "SELECT * FROM products where Description = 'SOME VALUE' order by SOME FIELD desc;

: http://dev.mysql.com/doc/refman/5.7/en/select.html

mysqli_* mysql_*.

, mysql_*, PHP 7.

mysqli: http://php.net/manual/en/book.mysqli.php

+2

, select - :

SELECT description 
FROM products
ORDER BY <column name> desc;

. , , ORDER BY.

. WHERE, , , - :

SELECT description
FROM products
WHERE description = 'some specific description';

, ORDER BY.

0

, SQL.

, , :

:

SELECT * FROM products;

:

SELECT * FROM products WHERE product_category=foo;

(ASC) (DESC):

SELECT * FROM  products ORDER BY product_id DESC;

:

SELECT * FROM products 
WHERE product_category = foo 
ORDER BY product_id DESC;

SQL , . , mysql_*, PHP 7. mysqli_*.

0

. - . , , !

Have a great day!

0
source

Source: https://habr.com/ru/post/1629221/


All Articles