Portal Home > Knowledgebase > Articles Database > URGENT "deadline news"
URGENT "deadline news"
Posted by argenty, 10-30-2010, 03:00 PM |
Hello, i need a help as quick as possible.
I am running this sql query:
It can show me the 3 lastest news,
but i like to bring up all other news, with another query
I'm still seeing two of the deadline news, can you help please ?
Thanks
|
Posted by speckl, 10-30-2010, 03:05 PM |
Second query you need to change $row to something else.
|
Posted by argenty, 10-30-2010, 03:14 PM |
i changed, samething,
I think the problem is only one is no coming, i like the 3 latest news to disapear in my second query.
|
Posted by speckl, 10-30-2010, 04:21 PM |
Ah, you totally screwed this code up.
Moderator note: Seeing code in the mobile view doesn't wrap lines into view.
You need to structure your code like this. This code will get all the news. If you just want to show the last 3 then add LIMIT 3 on the end of the query.
|
Posted by speckl, 10-30-2010, 04:26 PM |
Sorry reread... if you want to skip the first 3 rows in the database then you would add something like this...
LIMIT 3, 10
The 3 would be how many results to skip. The 10 would be how many you want to show.
|
Posted by argenty, 10-30-2010, 04:52 PM |
Yeah, i like to skip the used rows, i tryed but didn't work
|
Posted by Doh004, 10-30-2010, 05:01 PM |
What did it return?
|
Posted by argenty, 10-30-2010, 05:09 PM |
it's working now, i added more rows, now i can see the different, thnx so much
|
Posted by argenty, 10-30-2010, 05:17 PM |
what if i'm paging the result, like:
|
Posted by speckl, 10-30-2010, 05:34 PM |
Just keep using the LIMIT function. You're on the right track. The easiest thing to do is use real numbers for the variables, make sure it works, THEN try and figure out the code needed.
Hint: Most people use $_GET to keep track on what page is needed and how many results to show.
|
Posted by tim2718281, 10-31-2010, 02:12 PM |
The problem is that the variable $id is set each time you fetch one of the first three rows; that is, $id contains the id of the third story.
So in the second part of the code, only the third story is omitted.
You've coded round that, and introduced a new bug: if a new story is added between the first part of the code and the second, it will be skipped, and one of the first three stories will be shown instead.
I would keep a list of all the ids displayed in the first part, and then in the second part check each id against that list. (Or I suppose code the SQL query for the second part using a condition: id not in ... )
|
Add to Favourites Print this Article
Also Read