Hello all,
Sorry, this really ain't a CC question, but a general php/mysql question.
For showing data on my website I have several tables and they are linked with each other by the LEFT JOIN.
The first table that I have is a table with the airline_id and aircraft_id. This table only contains numbers. Each airline (airline_id) has it's own number and this also counts for the aircraft (aircraft_id).
Via a LEFT JOIN this table is linked to my Airlines and Aircraft table. In the Airline table I have the columns airline_id (this is a number) and name (the name of the airline). In my Aircraft table I have the columns aircraft_id1 (this is a number) and name1 (this one contains the name of the aircraft).
This works very well.
In my php script I make first a LEFT JOIN with the tables above and after that (via a LEFT JOIN) it gets the data from my content table (which contains the information about all my pages (title, alias, category, etc).
The php code is working fine for me and on my website it shows all the aircraft that an airline uses (it compares the title of the webpage with the airline name to show the right aircraft). The aircraft that are shown here are linkable (so if I click on them, I go to that aircraft page). But the problem I have, I don't have a page of every aircraft (so the link is not working).
So I need some kind of way to check if that article/page exists or not. If it exist it shows the <a> tags (for the link) and if it not exist, it just shows plain text (not linkable).
Can someone help me with this?
This is my php code:
At the bottom of the script I have my if-else statement. I think I am doing something wrong there but I am not sure.😶
could someone help me with this problem?
Kind regards,
Ruud
Sorry, this really ain't a CC question, but a general php/mysql question.
For showing data on my website I have several tables and they are linked with each other by the LEFT JOIN.
The first table that I have is a table with the airline_id and aircraft_id. This table only contains numbers. Each airline (airline_id) has it's own number and this also counts for the aircraft (aircraft_id).
Via a LEFT JOIN this table is linked to my Airlines and Aircraft table. In the Airline table I have the columns airline_id (this is a number) and name (the name of the airline). In my Aircraft table I have the columns aircraft_id1 (this is a number) and name1 (this one contains the name of the aircraft).
This works very well.
In my php script I make first a LEFT JOIN with the tables above and after that (via a LEFT JOIN) it gets the data from my content table (which contains the information about all my pages (title, alias, category, etc).
The php code is working fine for me and on my website it shows all the aircraft that an airline uses (it compares the title of the webpage with the airline name to show the right aircraft). The aircraft that are shown here are linkable (so if I click on them, I go to that aircraft page). But the problem I have, I don't have a page of every aircraft (so the link is not working).
So I need some kind of way to check if that article/page exists or not. If it exist it shows the <a> tags (for the link) and if it not exist, it just shows plain text (not linkable).
Can someone help me with this?
This is my php code:
<?php
$con = mysql_connect("xxxx","xxxx","xxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxxx", $con);
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if ($option=="com_content" && $view=="article") {
$ids = explode(':',JRequest::getString('id'));
$article_id = $ids[0];
$article =& JTable::getInstance("content");
$article->load($article_id);
$title_artikel = $article->get("title");
// Construct our join query
$query = "
SELECT DISTINCT
Airline_Aircraft.airline_id, Airlines.airline_id, Airlines.name, Airline_Aircraft.aircraft_id, Aircraft_id1, Aircraft.name1, d7ul5_categories.id, d7ul5_categories.path, d7ul5_content.id, d7ul5_content.title, d7ul5_content.alias, d7ul5_content.catid "."
FROM
Airline_Aircraft"."
LEFT JOIN
Aircraft "."
ON
Airline_Aircraft.aircraft_id = Aircraft.aircraft_id1
LEFT JOIN
Airlines "."
ON
Airline_Aircraft.airline_id = Airlines.airline_id
LEFT JOIN
d7ul5_content "."
ON
Aircraft.name1 = d7ul5_content.title
LEFT JOIN
d7ul5_categories "."
ON
d7ul5_content.catid = d7ul5_categories.id
WHERE "." Airlines.name = '$title_artikel' ORDER BY Aircraft.name1 ASC" ;
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result))
{
if ( d7ul5_content.title == 0 )
{
echo $row['name1']."<p />";
}
else
{
echo "<a href='../".$row['path']."/".$row['id']."-".$row['alias']."'>".$row['name1']."</a><p />";
}
echo "<br />";
}
}
?>
At the bottom of the script I have my if-else statement. I think I am doing something wrong there but I am not sure.😶
could someone help me with this problem?
Kind regards,
Ruud