A
A
andizura2021-07-31 23:52:16
PHP
andizura, 2021-07-31 23:52:16

How to get data from database using PHP?

Need to get data from price column from this table
6105b59584e2c147780626.jpeg
Quoting help from module
Paste in php to be executed on each line being processed. The result of the execution must be assigned to the $result variable. For example, if you want to import/export the value 52 into the above database field, write: $result = 52;. In the execution scope of this php, the following are available: the $num_row variable with the number of the row being processed (excluding the first line with column names, if present in the file), the $result_xpath variable with the result of xPath processing (if configured above). The values ​​in the columns of the corresponding row are also available. These values ​​will be stored in the variable: ${'Column name'}. You can also change the values ​​in these columns. For example, if you want to process the value 5 in the column called Quantity of the corresponding row, write: ${'Quantity'} = 5; To work with the database, use the standard OpenCart db object. For example, to retrieve the contents of the products table, write: $products = $this->db->query("SELECT * FROM " . DB_PREFIX . "product");

It is necessary that the $result variable contains the values ​​from the price column
. I tried this:

$products = $this->db->query("SELECT price FROM " . DB_PREFIX . "oc_product_special");
$result = $products;

Does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
no_one_safe, 2021-08-01
@andizura

It seems that the problem is here DB_PREFIX . "oc_product_special"
Look at what you have equal to DB_PREFIX and correct the code. For certain DB_PREFIX or "oc" or "oc_"
That is you receive the goods from the table oc_oc_product_special, and it is not present. You added the prefix 2 times, most likely.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question