how to retreive data from multiple tables...
Posted: Thu Aug 22, 2002 4:44 pm
How can I retreive data from multiple tables?
I have three tables to use in this script.
Table A - Topic_id, Topic_title, Topic_view etc...
Table B - Post_id, Topic_id etc...
Table C - Post_id, Post_text
Now my script gets the topic_id, topic_title, topic_view in a page called pagea.php
And I need to retreive the post_text from table from the link .
In order to do that, I need to use the topic_id to find post_id in table b and then used post_id to retreive the post_text.
Thanks in advance for sharing your knowledge.
I have three tables to use in this script.
Table A - Topic_id, Topic_title, Topic_view etc...
Table B - Post_id, Topic_id etc...
Table C - Post_id, Post_text
Now my script gets the topic_id, topic_title, topic_view in a page called pagea.php
Code: Select all
if (!empty($_GETї'start'])) $start = $_GETї'start'];
echo "<table class=justtext bgcolor=#000000 border=0 cellpadding=1 cellspacing=1>\n";
echo "<TR>";
echo "<TD width=460 height=45 bgcolor=#009900> <b>Topic Title</b></TD>";
echo "<TD width=60 bgcolor=#009900> <b>View</b></TD>";
echo "</TR>";
for ($i = $start; $i < ($num_items + $start); $i++)
{
echo "<TR>\n"
."<TD width=460 height=30 bgcolor=".row_color($i)."> <a href="pageb.php?topic=$i&start=$start">".$arrayї$i]ї"topic_title"]."</a></TD>\n"
."<TD width=60 bgcolor=".row_color($i)."> ".$arrayї$i]ї"topic_views"]."</TD>\n"
."</TR>";
}
echo "</TABLE>";Code: Select all
;<a href="view_gossips.php?gossip=$i&start=$start">".$arrayї$i]ї"topic_title"]."</a>In order to do that, I need to use the topic_id to find post_id in table b and then used post_id to retreive the post_text.
Thanks in advance for sharing your knowledge.