I need to display an text in an row, based on an value from other table, I will explain... step by step to be all very CLEAR.
The table called "links" have an row called "title_id"
This row "title_id" from "links", have THE SAME value in other table called "titles" in the row named "id".
The table "titles" have another row called "title" - and tis is wath i need to display in this way...
a href= ..../>TABLE links row title_id = to TABLE titles row id -> DISPLAY HERE table titles row title (based on row title_id from the table links) < /a...
I hope you can understand, the result must be (a href=...>TEXT MOVIE TITLE< /a>)
Here is the base code, wath I need to change (I have commented the part wath need changes):
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, label, title_id, season, episode, approved FROM links WHERE approved = 1 order by id desc LIMIT 30 OFFSET 1";
$result = $last_id = $conn->query($sql);
if ($result->num_rows > 0)
{
echo "<table><tr><th>ID</th><th>Audio</th><th>URL</th><th>Temporada</th><th>Episodio</th><th>Aprobado</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["id"]."</td><td>".$row["label"]."</td>";
echo "<td>";
if (empty($row['episode'])) {
echo "<a href=";
echo '/peliculas-online/'.$row["title_id"];
echo ">HERE MUST HAVE THE VALUE FROM TABLE titles -> row title - based on $row["title_id"] </a>";
// -------------------------
}
else {
echo "<a href=";
echo '/series-online/'.$row['title_id'].'/seasons/'.$row['season'].'/episodes/'.$row["episode"];
echo ">HERE MUST HAVE THE VALUE FROM TABLE titles -> row title - based on $row["title_id"] </a>";
// -----------------------------------
}
echo "</td>";
echo "<td>".$row["season"]."</td><td>".$row["episode"]."</td><td>".$row["approved"]."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
Aucun commentaire :
Enregistrer un commentaire