I’ve got a news script which cuts news by paragraphs on the main page. I want users to enter a number after which paragraph the news should be cut. That number is is also stored in the database.
My current code:
SUBSTRING_INDEX(newsText, "\n", newsShortbreaks + 1)
Users should also be able to show the whole text by leaving that field blank. Problem: there’s still only one parahraph because NULL + 1 = 1.
Does anyone has a nicer way to do this?
It’s good to use in your select/update/insert to following structure:
so in case when
newsShortbreaks =nullyou get just newsText.