Hi everyone, i have been struggling with passing multiple url parameters for quite some time and would be extremely grateful to receive some advice and guidance!
What i ultimately would like to achieve is to pass two parameters in the url, one being the name of a table from a mysql database, and the other being an id. So the url would look like: ...example.com?table=(table name)&id=(id of content). I would like it so that when the name of the table is changed in the url, the content from that table will be displayed. For instance,
...example.com?table=test1&id=1
...example.com?table=test2&id=1
would fetch different data from the two different tables. The reason for this is that i will be using a single template, in which according to the url parameters, will display different information from different tables.
So far i am only able to fetch the id's from one table at a time that i have defined in the query. After what feels like a million attempts for well over a week i am stumped and have gone back to my original code displayed below. Any help with this would be extremely appreciated. Many thanks.
function global_nav() {
$conn = connect();
$sql = "SELECT * FROM article";
$result = mysql_query($sql);
if(!$result)
{
echo "DB Error, could not process menu items.<br/>MySQL Error: ".mysql_error();
exit;
}
while($row=mysql_fetch_array($result))
{
$id = $row['id'];
echo '<a class="global" href="article.php?id='.$id.'">'.$row['articleTitle'].'</a>'; // 'articleTitle' being the name of the column in the table.
}
closeconnection($conn);
}