ketanco
08-07-2009, 11:47 AM
Can you use part of a table name based on from what table the data is displayed at that moment? Lets say the data is being displayed from newsbbb. Can I take that bbb and use it to produce the link? so that when the user hits (more...) link, he goes to that table...Please see the last line of code in my question.
Say I have a few tables and with a statement like below, I am displaying the latest dated entry when looking at all of those tables.
$query=mysql_query(SELECT col1, col2, col3, date FROM newsaaa)
UNION
(SELECT col1, col2, col3, date FROM newsbbb)
UNION
(SELECT col1, col2, col3, date FROM newsccc)
ORDER BY date DESC
LIMIT 1
Then I want to display the values of the selected row from the selected table, such as:
while ($row = mysql_fetch_array($query)) {
echo"<p class='newstitle1'>" . $row['date']."<br/>". $row['title'] . "</p>".
"<p id=newstext1>" . $row['paragraph1']."<br/>"."<br/>";
$b=$row['id'];
echo"<a href='http://www ..com/(xxx)*/display_(xxx)*_whole.php?id=$b'".">"."(more...)"."</a>" ; }
Please look at the last echo statement. I want to display the proper link name based on table name in the link...shown by (xxx)
Say I have a few tables and with a statement like below, I am displaying the latest dated entry when looking at all of those tables.
$query=mysql_query(SELECT col1, col2, col3, date FROM newsaaa)
UNION
(SELECT col1, col2, col3, date FROM newsbbb)
UNION
(SELECT col1, col2, col3, date FROM newsccc)
ORDER BY date DESC
LIMIT 1
Then I want to display the values of the selected row from the selected table, such as:
while ($row = mysql_fetch_array($query)) {
echo"<p class='newstitle1'>" . $row['date']."<br/>". $row['title'] . "</p>".
"<p id=newstext1>" . $row['paragraph1']."<br/>"."<br/>";
$b=$row['id'];
echo"<a href='http://www ..com/(xxx)*/display_(xxx)*_whole.php?id=$b'".">"."(more...)"."</a>" ; }
Please look at the last echo statement. I want to display the proper link name based on table name in the link...shown by (xxx)