Jump to content

fetching data from multiple tables


aneeb
 Share

Recommended Posts

Hey everyone! i am having some problem. In my code i am fetching data from multiple tables, but the code is having some problem it give me "mysql_fetch_array() expects parameter 1 to be resource, boolean given " error ... here is my code

<?php$localhost="localhost";$dbuser="root";$dbpass="";$dbname="shoppro";$connect=mysql_connect($localhost,$dbuser,$dbpass);if ( !$connect ){echo "Error connecting to database.\n";}mysql_select_db("$dbname",$connect);$count = "select count(*)-1 from core_store_group";$i = '';$sql = '';for($i=0;$i<$count;$i++){$sql = "select name,price,short_description,sku,weight,promotion from catalog_product_flat_'".$i."'". "UNION ALL";}$query=$sql.substr(0,$sql.strlen($sql)-9);$result=mysql_query($query);while($row=mysql_fetch_array($result)){echo $row['name'];}?>

please help me !!

Link to comment
Share on other sites

$i = 1;$sql = "select name,price,short_description,sku,weight,promotion from catalog_product_flat_'".$i."'". "UNION ALL";$query=$sql.substr(0,$sql.strlen($sql)-9);echo $query;//It seems you have problesm with the concatenation of values in the variable $query. Please inspect it again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...