Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

sql help


Recommended Posts

I am trying to change the following to just pull from 1 category, in this case categories_id=53. So far I have managed to change the name of all cats to be the same and have come up with various errors.


 $sql = "SELECT * FROM products_to_categories ORDER BY categories_id";
	$records = mysql_query($sql, $conn);

	Print "<table border=3 width=100%>";	
	Print "<tr><td><b>Part Number</b></td><td><b>Category</b></td><td><b>Description</b></td><td><b>Price</b></td></tr>";
	$i = 0;														

	while ($table = mysql_fetch_array($records)) {

		$product = $table['products_id'];			
		$category = $table['categories_id'];
		$desc_id = $product;

		$sql = "SELECT categories_name, categories_id FROM categories_description WHERE categories_id = $category";
		$category = mysql_query($sql, $conn);
		$category = mysql_fetch_array($category);
		$category = $category['categories_name'];

		$sql = "SELECT products_id, products_model, products_price, products_image FROM products WHERE products_id = $product";
		$product = mysql_query($sql, $conn);
		$product = mysql_fetch_array($product);
		$part = $product['products_model'];
		$price = $product['products_price'];
		$picture = $product['products_image'];
		$price = substr($price,0, strlen($price) - 2);

		$sql = "SELECT products_id, products_description FROM products_description WHERE products_id = $desc_id";
		$description = mysql_query($sql, $conn);
		$description = mysql_fetch_array($description);
		$description = $description['products_description'];




Link to comment
Share on other sites


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

  • Create New...