I do not understand anything at all, the request seems to be correct. But does not display a string with the desired id;

<?php $mysqli = new mysqli("host", "user", "pass", "bd"); if ($mysqli->connect_errno) { echo "Не удалось подключиться к MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $id = $_POST['productID']; $res = $mysqli->query("SELECT SS_products FROM title WHERE id = $id"); echo $res; ?> 

The query is kind of correct, but the result of the query is empty.

  • one
    $ res is not the result returned by the query, but a handle to access the data. read the documentation for mysqli-> query and see examples there - Mike

1 answer 1

There were already a lot of similar questions. And everything is written in the documentation in detail: http://php.net/manual/ru/mysqli.query.php

If the SELECT, SHOW, DESCRIBE, or EXPLAIN queries succeed, mysqli_query () will return a mysqli_result object.

We look what to do with it and see:

mysqli_result :: fetch_all - Selects all rows from the result set and puts them into an associative array, a regular array, or both

 $res = $mysqli->query("SELECT SS_products FROM title WHERE id = $id"); $result = $res->fetch_all(); print_r($result);