Here is exactly how you can do it :
LINKING TWO TABLES IN MYSQL :
It's very easy in order to link two tables in MySQL.You need to have at least one column (field) in each table similar to each other to relate them to each other.
For Example :
In your case you need to have your both table structures like this way :
Table : researchprojects => id,publications
Table : publi => publi_id,publi_year
YOUR CASE:
As in your case you have all id's
mentioned in your one row as :
researchprojects
|
V
---------------------------
publications
800,900,1000
---------------------------
publi
|
V
---------------------------
publi_id publi_year
800 2012
800 2013
900 2014
900 2015
1000 2016
1000 2017
---------------------------
CODE TO SHOW THE TABLES DATA OUTPUT:
<?php
// Assuming that $publications will hold all fetched values from researchprojects table
// Also assuming that $publi will hold all fetched data from publi table
$publi_ids = explode(",",$publications[0]['publications']);
//Now you have all ids in array in $publi_ids
//So moving forward with the code
foreach ($publi_ids as $publi_id) {
echo "<h1>".$publi_id."</h1>";
$id = $publi_id;
$query = mysqli_query($mysqli,"SELECT * FROM publi WHERE publi_id='$id'");
$publi_data = array();
while ($rows = mysqli_fetch_array($query)) {
$publi_data[] = $rows;
}
foreach ($publi_data as $publi_row) {
echo "Year :".$publi_row['publi_year']."</br>";
echo "</br></br></br>";
}
echo "</br></br></br></br>";
}
?>
OUTPUT :
800
Year : 2012
Year : 2013
900
Year : 2014
Year : 2015
1000
Year : 2016
Year : 2017