View Full Version : calling from-1 database, 2 tables

10-26-2002, 04:12 AM
U guys are great! thanks for all your help here

OK, what if I want to call from 1 database, from 2 fields in 2 diff tables?

how would i select them?

for php output.. I got calling one down from one table..but now from 2 diff tables

thanks again

10-26-2002, 08:50 AM

10-26-2002, 04:23 PM
thanks guys/girls, you are extremely beneficial to the community. That was a great site, and extremely helpful. The problem I have is just not know what the variables, and stuff are actually called..So it is hard to search through a million pages on the web looking. THANKS AGAIN !!!

10-26-2002, 06:44 PM
Well you need to provide us with more than just talking about it otherwise we can't help. Right now all I can do is say the same thing you can find in that tutorial I posted:

SELECT table1.field1, table2.field1 FROM table1, table2 WHERE where condition here;

10-27-2002, 12:44 AM
lol am sorry . I will think of that next time, but it wont go :-( I am missing something

$db_name = "user_mapforum";
$table_name = "ibf_post";
$table_name2 = "ibf_topics";
$connection = @mysql_connect("localhost", "user name", "pass") or die("Couldn't Connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "SELECT ibf_posts.ibf_posts, ibf_topics.title FROM $table_name, $table_name2
WHERE ibf_topics.title = ibf_posts.post_date";
$result = @mysql_query($sql, $connection) or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result)) {
$ibf_topics = $row['ibf_topics'];
$ibf_posts = $row['ibf_posts'];
$display_title .= "<p><strong>$ibf_topics</strong></p>";
$display_post .= "<p><strong>$ibf_posts</strong></p>";

I keep getting couldnt execute query..I think ..well I am missing something..I am calling with echo command on another page using the $display

ohh well I hope people can sort through that mess. thanks

10-28-2002, 03:33 PM
Umm Im lost hellp lol, I still can not figure where my error is

10-28-2002, 04:44 PM
Try hardcoding your table names in first. If the query cannot find the tables then that will stop it from running.