dauruk0512 Posted August 18, 2015 Share Posted August 18, 2015 (edited) 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 I need show the row with max id ( Done ) I need show data limit 1 where id != row with max id (Done) 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 August 18, 2015 by dauruk0512 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 18, 2015 Share Posted August 18, 2015 Save the IDs of the other 2 records that you're showing and use those in the other SQL query to get records without those IDs. Link to comment Share on other sites More sharing options...
dauruk0512 Posted August 19, 2015 Author Share Posted August 19, 2015 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 More sharing options...
justsomeguy Posted August 19, 2015 Share Posted August 19, 2015 Wherever you call those functions you can save the IDs of the records that were returned, and send those IDs to another function to get everything but them. Link to comment Share on other sites More sharing options...
dauruk0512 Posted August 27, 2015 Author Share Posted August 27, 2015 can you give simple code of your logic ? thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted August 27, 2015 Share Posted August 27, 2015 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 More sharing options...
dauruk0512 Posted September 2, 2015 Author Share Posted September 2, 2015 Solved thanks moderator for reply, hope you are doing great today ! +1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now