Jump to content

How can i select articles based on images


dauruk0512
 Share

Recommended Posts

Hi, need some advice to do logic in my table casue i never face this before, hope you guys help me out this issue

 

i need to show data from database and the image upload here cause cannot upload here to big system respond

 

but let me tell here what i stuck it

 

  1. I need show the row with max id ( Done )
  2. I need show data limit 1 where id != row with max id (Done)
  3. I need show all data without max id (point 1) and point 2

Thanks, and think that it can handle by css by hidden or by selector asecending but still figure out how.

 

 

 

edit : i use codeiigniter

Edited by dauruk0512
Link to comment
Share on other sites

I know but in codiegnter i don't understand of it how to save variable itself

 

here is my model

//detail trend function detailtrend($art_slug)	 //consider art_slud is the max id from table		{		return $this->db->query("SELECT * FROM `articles` WHERE art_slug='$art_slug'");	}//sisa trend function lefttrend($art_slug)			{		return $this->db->query("SELECT * FROM `articles` WHERE art_slug != '$art_slug' and art_jenis='TREND' limit 1");	}//how can i write funtion as your said above

Thanks for comment

 

 

Freddy Sidauruk

Link to comment
Share on other sites

You understand how to get results from the database, right? So, get the IDs of the records that were returned, save them in a variable. In SQL you can use != or NOT IN to exclude those. Using NOT IN would be slower.

SELECT * FROM table WHERE id != 1 AND id != 2SELECT * FROM table WHERE id NOT IN (1, 2)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...