Member Avatar for OldDeveloper01

At the moment i have dynamic list which displays the latest products added to the inventory list. I want to display birthday cards from the category. In my database i have the column 'category', and in a form you can select different options with values one being birthday.

This is the code i have for the dynamic list, what change would i need to make so it displays the birthday cards?

div id="position" style="z-index: 1; width: 900px; height: 50px; position: absolute; top: 140px; left: 250px">
	<?php 
	
		// Run a select query to get my letest 6 items
		// Connect to the MySQL database  
		require ("scripts/connect.php");
		 
		$dynamicList = "";
		$sql = mysql_query("SELECT * FROM products ORDER BY dateadded DESC LIMIT 6");
		$productcount = mysql_num_rows($sql); // count the output amount
		if ($productcount > 0) {
			while($row = mysql_fetch_array($sql)){ 
		             $id = $row["id"];
					 $productname = $row["productname"];
					 $price = $row["price"];
					 $dateadded = strftime("%b %d, %Y", strtotime($row["dateadded"]));
					 $dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
		        <tr>
		          <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventoryimages/' . $id . '.jpg" alt="' . $productname . '" width="77" height="102" border="1" /></a></td>
		          <td width="83%" valign="top">' . $productname . '<br />
		            £' . $price . '<br />
		            <a href="product.php?id=' . $id . '">View Product Details</a></td>
		        </tr>
		      </table>';
		    }
		} else {
			$dynamicList = "We have no products listed in our store yet";
		}
		mysql_close();
		
		?>
		
	<table >
	<tr>
	<td><?php echo $dynamicList; ?></td>

Thanks for any help!

In your code you use one table ‘dateadded’ and you want to display a birthday card depending on someone birth date. Is that right till now? Sow there must be a relevance to your table , give your SHOW CREATE TABLE dateadded and describe the fields of the table (if you don’t already have comments on them (that you should)).

Member Avatar for OldDeveloper01

Sorry that code is what i followed to display the 6 latest additions to the inventory list.

Now i want to use that code to display only the cards that in the category column have been set as 'birthday' cards.

Sorry for confusion.

I would optimally like to have a system where the admin manager can view the birthday cards in a drop down menu. And from this assign them to selected areas in a table with the same information that is in the dynamicList. The attachment may help you understand what i am saying.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.