Welcome Guest, Not a member yet? Register   Sign In
Need help news and headlines
#1

[eluser]BaRzO[/eluser]
Hi all,
i need to find a way to solve this problem

at admin panel user can add news categories etc.
at the main page i have to show headlines ( ten headlines )
and at the below i want to shoe 11 news but which are not same the headlines
i haven't find any way any idea for this
sorry for pour English
#2

[eluser]Pascal Kriete[/eluser]
Just to make sure I understand this correctly. You want to show 10 user defined headlines. And then a bunch of random news, which can be anything other than the headlines.

How are you storing them and how large is the pool of articles?
#3

[eluser]BaRzO[/eluser]
in 1 day about 50 - 70 news will be added. Not random news at the main page at the main page there is 2 box at 1st box i need to show 10 headlines and 2nd box latest 11 news but headlines and latest 11 should be not same...
#4

[eluser]Pascal Kriete[/eluser]
Righty-o.

When the user marks an article as a headline, you set a flag in the db - let's call that field is_headline.

To get your headlines you do:
Code:
$this->db->get_where('articles', array('is_headline' => 1) );

Then to get your news you would do:
Code:
$this->db->where('is_headline !=', 1);
$this->db->order_by("date", "desc");
$this->db->get('articles', 11, 0);
#5

[eluser]BaRzO[/eluser]
thanks for your reply
but i did this but...
for example
news table is like this
Code:
id  |   title   |   date    |   is_headline
1   |   test    |   time1   |   1
2   |   test    |   time2   |   0
3   |   test    |   time2   |   0
4   |   test    |   time3   |   1
5   |   test    |   time3   |   1
6   |   test    |   time3   |   0
7   |   test    |   time3   |   1
8   |   test    |   time3   |   1
9   |   test    |   time3   |   0
10   |   test    |   time3   |   1
11   |   test    |   time3   |   1
12   |   test    |   time3   |   1
13   |   test    |   time3   |   1
14   |   test    |   time3   |   1

At this table there is 0 values this is confusing me

i need 1 box whit 10 headlines and the 2nd box 11 news but this both box news must be differ and they are all new news Sad
#6

[eluser]Pascal Kriete[/eluser]
Now I'm confused. The ones mark your headlines. Everything with a zero isn't a headline so it's fair game for the news section.
#7

[eluser]BaRzO[/eluser]
Code:
SELECT n.news_id, n.news_title FROM news n
WHERE n.news_headline = 'N'
ORDER BY n.news_date DESC LIMIT 3


Code:
SELECT n.news_id, n.news_title FROM news n
WHERE n.news_headline = 'Y'
ORDER BY n.news_date DESC LIMIT 3

this queries looks ok but i have to collage garbage i mean user adding news but they forget to switch back to headlines N ( not ) when they are adding new news they click to headlines tick after all all news become as headlines Smile
#8

[eluser]Pascal Kriete[/eluser]
When they create a new headline, check how many headlines there are and if you already have 10 either display an error or simply remove the oldest.
#9

[eluser]BaRzO[/eluser]
When user adds new news i have to use this code i think Wink thanks for your help my friends thanks a lot...
Code:
UPDATE news n SET n.news_headline = 'N' where n.news_headline = 'Y' order by n.news_date DESC limit 1




Theme © iAndrew 2016 - Forum software by © MyBB