0

this is my first code in php. i am trying this off a tutorial i saw--

i am getting error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN products.products_id=products_description.products_id' at line 8

<?php
// Make a MySQL Connection
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());

// Get all the data from the "product" table
$result = mysql_query("SELECT * FROM products.products_id AS id,
products_description.products_name AS name,
products.products_quantity AS quantity,
products.products_weight AS weight,
products.products_price AS price,


LEFT JOIN products.products_id=products_description.products_id

") 
or die(mysql_error());  

echo "<table border='1'>";
echo "<tr> <th>Name</th> <th>Age</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
	// Print out the contents of each row into a table
	echo "<tr><td>"; 
	echo $row['id'];
	echo "</td><td>"; 
	echo $row['name'];
	echo "</td></tr>";
	echo $row['quantity'];
	echo "</td></tr>";
	echo $row['weight'];
	echo "</td></tr>";
	echo $row['price'];
	echo "</td></tr>";
} 

echo "</table>";
?>

thanks,

craig

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by shadowcrawler
0

The query sentense shoud be like

$result = mysql_query("SELECT products.products_id AS id,
products_description.products_name AS name,
products.products_quantity AS quantity,
products.products_weight AS weight,
products.products_price AS price  FROM products, products_description 
LEFT JOIN products.products_id=products_description.products_id
 ")

It should be the table name after "FROM", not the column name ;)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.