ok you asked for it 😃
so at the bottom im starting to return the related item.
$query = "SELECT raillink_destination_id, place_id, raillink_id, ticket_name FROM raillink_destinations
WHERE place_id = $place_id";
$result = mysql_query($query)
or die ("The system doesn't like your login details- please try again
with different ones.");
$row = mysql_fetch_assoc($result);
$place_id2 = $row['place_id'];
$raillink_id = $row['raillink_id'];
$ticket_name = $row['ticket_name'];
$raillink_destination_id = $row['raillink_destination_id'];
//echo $raillink_destination_id;
//echo $place_id2;
//echo $raillink_id;
$query2 = "SELECT raillink_id, toc_id, name FROM raillinks WHERE raillink_id = $raillink_id";
$result2 = mysql_query($query2)
or die ("The system doesn't like your login details- please try again
with different ones.");
$row2 = mysql_fetch_assoc($result2);
$toc_id = $row2['toc_id'];
$name = $row2['name'];
//echo $toc_id;
$query3 = "SELECT toc_id, name FROM tocs WHERE toc_id= $toc_id";
$result3 = mysql_query($query3)
or die ("The system doesn't like your login details- please try again
with different ones.");
$row3 = mysql_fetch_assoc($result3);
$toc_id = $row3['toc_id'];
$name2 = $row3['name'];
//echo $name2;
$query4 = "SELECT place_id, place_name FROM places WHERE place_id= $place_id";
$result4 = mysql_query($query4)
or die ("The system doesn't like your login details- please try again
with different ones.");
$row4 = mysql_fetch_assoc($result4);
$place_name = $row4['place_name'];
//////////////////////////////////////////////////////////////////////////////////////
// problems here in next two queries
//////////////////////////////////////////////////////////////////////////////////////
$query5 = "SELECT nlc_code, raillink_destination_id FROM raillink_interchange_stations
WHERE raillink_destination_id = $raillink_destination_id";
$result5 = mysql_query($query5)
or die ("The system doesn't like your login details- please try again
with different ones.");
while($row5 = mysql_fetch_array($result5))
{
$nlc_code = $row5['nlc_code'];
//echo $nlc_code;
//echo "<br />";
$query6 = "SELECT nlc_code, station_name FROM stations
WHERE nlc_code = $nlc_code";
$result6 = mysql_query($query6)
or die ("The system doesn't like your login details- please try again
with different ones.");
while($row6 = mysql_fetch_array($result6))
{
$station_name = $row6['station_name'];
// echo $station_name;
//$station_name2 = $station_name;
//echo $station_name;
}
}
// see if there is a match between the first related places field in the unique_places field
// to a place_id in the places table
$query7 = "SELECT * FROM places INNER JOIN unique_places
WHERE places.place_id = unique_places.related_place_1_id";
$result7 = mysql_query($query7)
or die ("The system doesn't like your login details- please try again
with different ones.");
$row7 = mysql_fetch_assoc($result7);
$related_place_1_id = $row7['related_place_1_id'];
// echo $related_place_1_id;
$query8 = "SELECT * FROM places WHERE place_id = $related_place_1_id";
$result8 = mysql_query($query8)
or die ("The system doesn't like your login details- please try again
with different ones.");
$row8 = mysql_fetch_assoc($result8);
$place_name2 = $row8['place_name'];
/////////////////////////////
/$connect = mysqli_connect("localhost","root","ARC0nl1n3!");
$rowcount = 0;
mysqli_select_db($connect,"rio_test");
$q = mysqli_query($connect,"SELECT nlc_code, station_name FROM stations
WHERE nlc_code = raillink_interchange_stations.nlc_code");
while ($abc = mysqli_fetch_row($q)) {
$rowcount++;
for ($k=0; $k<count($abc); $k++){
echo "<br />";
//print htmlspecialchars($abc[$k]);
$nlc_codes1 = htmlspecialchars($abc[$k]);
echo $nlc_codes1;
}
} /
// echo $station_name;
/////////////////////////
echo "<div class=\"title\">
<div style=\"float: left;\">$name</div><!-- Raillinks::name::end -->
<!-- Raillinks::toc_code::start --><div style=\"display: inline; float: right;\">$name2</div><!-- Raillinks::toc_code::end -->
</div>";
echo "<br />";
echo "Destination: <strong> $place_name, </strong>";
echo "<br /><br />";
////////////////////////////////
// get the TOC stuff
echo "<div id=\"stationname\">";
echo "Interchange Station:";
$query5 = "SELECT nlc_code, raillink_destination_id FROM raillink_interchange_stations
WHERE raillink_destination_id = $raillink_destination_id";
$result5 = mysql_query($query5)
or die ("The system doesn't like your login details- please try again
with different ones.");
while($row5 = mysql_fetch_array($result5))
{
$nlc_code = $row5['nlc_code'];
//echo $nlc_code;
//echo "<br />";
$query6 = "SELECT nlc_code, station_name FROM stations
WHERE nlc_code = $nlc_code";
$result6 = mysql_query($query6)
or die ("The system doesn't like your login details- please try again
with different ones.");
while($row6 = mysql_fetch_array($result6))
{
$station_name = $row6['station_name'];
echo "<strong> $station_name,</strong>";
}
}
echo "<br /><br />";
echo "<a href=\"../../raillinks_new/index.php?place_id=$place_id\">More Details >></a>";
// echo $place_id;
//}
echo "</div>";
if (isset($related_place_1_id)) {
echo "<br />";
echo "<div class=\"title\">
<div style=\"float: left;\">$place_name2</div>
<div style=\"display: inline; float: right;\">$name2</div>
</div>";
echo "<br />";
echo "Destination: <strong> $place_name, </strong>";
echo "<br /><br />";
////////////////////////////////
// get the TOC stuff
echo "Interchange Station: <strong> $station_name, </strong>";
echo "<br /><br />";
echo "<a href=\"../../raillinks_new/index.php?place_id=$place_id\">More Details >></a>";
}
/**if($place_results->numrows() > 0 )
{
while($row = $place->fetchrow())
{
$raillink_id = $row['raillink_id'];
}
} **/
//while ($row = mysql_fetch_assoc($result))
// echo $row["area_id"];
?>