Jump to content

Result display and sort


adman4054

Recommended Posts

I have a classified ad program where I need to export ads (items). This code displays a category, subcategory, ad title, description and price for each ad. I would like to display the category and subcategory followed by the all the ads from within the category and subcategory instead of repeating the category and subcategory for each ad. Any help would be appreciated, thanks in advance!  :)

 

 

 


function getExport() {

	$this->db->select("
	item.id AS item_id,
	item.title AS item_title,
	item.description AS item_description,
	item.price AS item_price, 
	subcategory.subcategory AS subcategory_subcategory, 
	category.category AS category_category,
	(SELECT IF(item.datestarts IS NULL AND item.dateexpires IS NULL,'PENDING',IF(item.datestarts <= UNIX_TIMESTAMP() AND item.dateexpires >= UNIX_TIMESTAMP(),'ACTIVE',IF(item.dateexpires <= UNIX_TIMESTAMP(),'EXPIRED',''))) FROM item WHERE item.id = item_id) AS item_status");

	$this->db->join('subcategory', 'subcategory.id = item.subcategory');
	$this->db->join('category','category.id = subcategory.category');
	$this->db->join('user','user.id = item.owner');
	return($this->db->get($this->table));

Link to comment
https://forums.phpfreaks.com/topic/247227-result-display-and-sort/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.