Jump to content

Selecting and displaying multiple Tables


theblt

Recommended Posts

Ok, I\'m trying to display info form many tables. 9 tables to be exact. And I can\'t get it to work at all. I put it all together and run it and nothing is echoed back. It only seems to work when I\'m only using 2 tables. Otherwise if it\'s 3 or more, it doesn\'t echo anything.

 

[php:1:f7a6cda346]<?php

//Connect to Database

mysql_pconnect(\"localhost\", \"user\", \"password\");

mysql_select_db(\"database\");

//Select Tables

$result = mysql_query(\"SELECT `aboutus`.*, `email_support`.*, `home`.*, `im_support`.*, `newsroom`.*, `page_options`.*, `portfolio`.*, `products`.*, `services`.* FROM aboutus, email_support, home, im_support, newsroom, page_options, portfolio, products, services \");

$r=mysql_fetch_array($result);

//Define Database Variables

//Page Options Variables

$pagetitle=$r[\"po_page_title\"];

$date_setting=$r[\"po_date_setting\"];

$siteroot=$r[\"po_site_root\"];

$footer=$r[\"po_footer\"];

//About Us Variables

$aboutus_content=$r[\"aboutus_content\"];

//IM Support Variables

$im_aim=$r[\"IM_aim\"];

$im_msn=$r[\"IM_msn\"];

$im_yahoo=$r[\"IM_yahoo\"];

$im_icq=$r[\"IM_icq\"];

//Email Support Variables

$email_address=$r[\"email_address\"];

$email_type=$r[\"email_type\"];

//Home Page Variables

$home_content=$r[\"home_content\"];

//Newsroom Variables

$news_id=$r[\"news_id\"];

$news_title=$r[\"news_title\"];

$news_date=$r[\"news_date\"];

$news_content=$r[\"news_content\"];

//Portfolio Variables

$prtf_id=$r[\"prtf_id\"];

$prtf_site_name=$r[\"prtf_site_name\"];

$prtf_site_address=$r[\"prtf_site_address\"];

$prtf_image_url=$r[\"prtf_image_url\"];

$prtf_site_description=$r[\"prtf_site_description\"];

//Products Variables

$prod_id=$r[\"prod_id\"];

$prod_name=$r[\"prod_name\"];

$prod_price=$r[\"prod_price\"];

$prod_description=$r[\"prod_description\"];

$prod_image_url=$r[\"prod_image_url\"];

//Services Variables

$serv_id=$r[\"serv_id\"];

$serv_name=$r[\"serv_name\"];

$serv_description=$r[\"serv_description\"];

$serv_image_url=$r[\"serv_image_url\"];

?>

<?php

echo $pagetitle.\"<br>\";

echo date(\"$date_setting\").\"<br>\";

echo $siteroot.\"<br>\";

echo $footer.\"<br>\";

echo $aboutus_content.\"<br>\";

echo $im_aim.\"<br>\";

echo $im_msn.\"<br>\";

echo $im_yahoo.\"<br>\";

echo $im_icq.\"<br>\";

echo $email_address.\"<br>\";

echo $email_type.\"<br>\";

echo $home_content.\"<br>\";

echo $news_id.\"<br>\";

echo $news_title.\"<br>\";

echo $news_date.\"<br>\";

echo $news_content.\"<br>\";

echo $prtf_id.\"<br>\";

echo $prtf_site_name.\"<br>\";

echo $prtf_site_address.\"<br>\";

echo $prtf_image_url.\"<br>\";

echo $prtf_site_description.\"<br>\";

echo $prod_id.\"<br>\";

echo $prod_name.\"<br>\";

echo $prod_price.\"<br>\";

echo $prod_description.\"<br>\";

echo $prod_image_url.\"<br>\";

echo $serv_id.\"<br>\";

echo $serv_name.\"<br>\";

echo $serv_description.\"<br>\";

echo $serv_image_url.\"<br>\";

?>[/php:1:f7a6cda346]

Link to comment
https://forums.phpfreaks.com/topic/959-selecting-and-displaying-multiple-tables/
Share on other sites

$result = mysql_query(\"SELECT `aboutus`.*, `email_support`.*, `home`.*, `im_support`.*, `newsroom`.*, `page_options`.*, `portfolio`.*, `products`.*, `services`.* FROM aboutus, email_support, home, im_support, newsroom, page_options, portfolio, products, services \");

 

I suspect the query is timing out. When you select from several table without any JOIN conditions, you get a \'cartesian\' join which combines every record with every other record in every table.

 

So if you have only 10 records in each of your 9 tables you get 10^9 rows returned - 1,000,000,000.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.