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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.