Answer the question
In order to leave comments, you need to log in
How to make it so that when displaying a table, information is displayed instead of id?
After the fetch, I output ShippingOffer.station_id , station_id refers to the table that contains the name of the stations. But when displaying on the screen, an id is drawn, how to make the value (station name) related to this id be displayed?
the code:
<?php
$host = 'localhost';
$user = 'mysql';
$pass = 'mysql';
$db_name = 'tguquest';
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name, $link);
$sql = mysql_query("SELECT ShippingOffer.shipping_starts_at, ShippingOffer.station_id FROM `ShippingOffer` JOIN `ShippingRequest` USING (station_id) WHERE ShippingOffer.station_id_end = ShippingRequest.station_id_end");
$i = 0;
while ($row = mysql_fetch_row($sql))
{
$arr_so[$i] = $row;
echo "<p>".$arr_so[$i][1]."</p>";
$i++;
}
?>
Answer the question
In order to leave comments, you need to log in
Check:
SELECT ShippingOffer.shipping_starts_at,
ShippingOffer.station_id,
s.name as StationName --<
FROM ShippingOffer
JOIN ShippingRequest USING (station_id)
LEFT JOIN station as s ON s.id = ShippingOffer.station_id --<
WHERE ShippingOffer.station_id_end = ShippingRequest.station_id_end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question