A
A
Alexander2018-03-05 14:57:45
PHP
Alexander, 2018-03-05 14:57:45

How to fetch data from database by parameter?

There are 2 databases in the structure, it should be implemented like this:
I enter a certain value, for example, the id of a product, and it gives me information from another database.
I thought it was necessary like this: 'SELECT * FROM `table_products` WHERE 'id_product' = {$id}'
But it doesn't work, tell me! Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cicatrix, 2018-03-05
@cicatrix

Are you sure you mean 2 DIFFERENT DATABASES and not 2 different tables?
In the general case, for two different databases, you need to create 2 different connections and make sequentially first one request to one database, then the second - to the second.
If you meant 2 different tables, then here is some food for thought (JOIN) .
You need to use the JOIN statement to join one table to another based on some criteria, usually using FOREIGN KEYs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question