I'm trying to setup a news manager to allow the people to add news stories, either internally or externally.
I have a form setup to allow them to add the news items, and inserting, but I want to add the part that allows them to make the news item external.
I use the following query to insert the news into the database:
$query = "INSERT INTO news(date, headline, story, external, url) VALUES(NOW(), '$headline', '$story', '$external', '$url')";
Right now I have external set as an option field with Yes = 1 and No = 0. What I'd like to do, if possible, is if there is any text in the URL text field name=url, then automatically set external = 1, if there is no text in the form field url then set external = 0.
So, if I have:
Headline: <input size="50" maxlength="250" type="text" name="headline">
URL: <input size="50" maxlength="250" type="text" name="url">
Article: <textarea name="story" id="news" cols="70" rows="15"></textarea>
What I want is if there is any text what-so-ever in the URL input then to insert the text into the database in the field 'url' and also to insert a value of 1 into the database field of 'external'. If there is no text in the URL input then insert a value of 0 into the database field of 'external'.
I just don't know how I need to modify my query to do this...
Thanks!