0

I am trying to do a website where there will be a list of suppliers and clicking on the supplier will show the data of that particular supplier on another page. Currently I am only able to do it with one database.

Is it possible to link multiple database as the other database have other supplier's data such as purchase records?

<?php
include 'config.php'; 
 $connect = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
$id = $_GET['id'];

$result = mysqli_query($connect,"SELECT * FROM my30_rsl WHERE id = $id");
?>

Let say I want to link another database:

mysqli_query($connect,"SELECT * FROM bought WHERE id = $id");

Note the: The table structure for both database is similar where SupplierName and Company data are the same

my30_rsl bought

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
wt1155
  • 129
  • 1
  • 1
  • 8
  • Yes, you can join multiple tables, look into https://dev.mysql.com/doc/refman/8.0/en/join.html and many tutorials out there. Just Google "how to join tables in mysql"; you can add "php" to that also. Edit: Here's one: http://www.mysqltutorial.org/mysql-join/ which I enjoy reading myself; it's a good site. – Funk Forty Niner Jul 19 '18 at 02:13
  • You should also look into using a prepared statement. Your present code if you didn't know, is open to an SQL injection. Or, add `(int)` to your GET array assignment if it's to always be an integer. – Funk Forty Niner Jul 19 '18 at 02:17

0 Answers0