| 
	
 | 
 Posted by Steve on 09/10/06 21:18 
> Steve, 
>  
> The code you've posted shouldn't do that.  Mind posting ALL of you  
> rcode?  For instance - where do you fetch the data and retrieve the  
> category? 
>  
 
Here you go. 
 
<?	 
if (isset($_POST['parts_choice'])) 
{ 
   	$parts_choice = $_POST['parts_choice']; 
	if (substr($parts_choice,0,6) != "Choose") 
	{ 
		if (db_connect()) 
		{ 
		 
			$query2 = "select parts.category, parts.part_number,parts.years, parts.description, parts.price, parts.graphic, 					categories.description  
AS Category"; 
			$query2 = $query2." FROM parts INNER JOIN categories on parts.category = categories.code"; 
			$query2 = $query2." where parts.category = '$parts_choice'"; 
		 
			//echo("<p class=\"text\" align=\"center\">\$query2= $query2</p>"); 
	 
			$result2 = mysql_query($query2) or die(mysql_error()); 
			$num_results2 = mysql_num_rows($result2) or die(mysql_error()); 
	 
			if ($_POST['get_parts'] == "Display Parts") 
			{ 
				$category_name = mysql_result($result2,0,6); 
	?> 
				<center> 
				<h2><?php echo $category_name ?></h2> 
				<table border="1" cellpadding="5"> 
				<tr> 
				<th>Part Number</th> 
				<th>Years</th> 
				<th>Description</th> 
				<th>Price</th> 
				<th>Picture</th> 
				</tr> 
	<? 
			} 
			else 
			{ 
				echo("<p class=\"text\" align=\"center\">There was an error.</p>"); 
			}	 
		 
			for ($i = 0;$i < $num_results2; $i++) 
			{ 
				$row2 = mysql_fetch_array($result2); 
	 
				if (!$row2) 
				{ 
					echo "No parts found for this category."; 
				} 
	?>		 
				<tr> 
				<td><?php echo $row2["part_number"]?></td> 
				<td><?php echo $row2["years"]?></td> 
				<td><?php echo $row2["description"]?></td> 
				<td>$<?php echo $row2["price"]?></td> 
				<?php 
				if (strlen($row2["graphic"]) > 0) 
				{				 
				?> 
					<td align="center"><img src="graphics/<?php echo $row2["graphic"].".jpg"?>" border="0"></td> 
				<?php 
				} 
				else 
				{ 
				?> 
					<td>No picture available</td> 
				<?php 
				}			 
				?> 
				</tr> 
	<? 
			} 
	?> 
			</table> 
			<br> 
			<br> 
	 
	<? 
		} 
	}	 
} 
do_html_footer(); 
?>
 
[Back to original message] 
 |