Working on an RSS file, need help with an IF statement...
Posted: Sat Nov 07, 2009 11:56 pm
Here is my situation. I have a table that looks something like this:
title date
-------------------------------
Gravity 01/08/2009
Science 02/15/2009
04/01/2009
Tech 05/05/2009
.
.
. (etc)
Notice that some entries have titles, some do not. ALL have a date.
So in my RSS feed I need a basic if statement that says, "If the title is present, use that as the title. Otherwise use the date as the title. For some reason in the database the title field is marked as blank, '', instead of being NULL.
Simple, no? But my little code isn't working! Here is what I have:
strlen doesn't work. I've tried empty, is_null and a few others. Can someone help me out?
Thanks!
Craig
title date
-------------------------------
Gravity 01/08/2009
Science 02/15/2009
04/01/2009
Tech 05/05/2009
.
.
. (etc)
Notice that some entries have titles, some do not. ALL have a date.
So in my RSS feed I need a basic if statement that says, "If the title is present, use that as the title. Otherwise use the date as the title. For some reason in the database the title field is marked as blank, '', instead of being NULL.
Simple, no? But my little code isn't working! Here is what I have:
Code: Select all
if (strlen($_GET['title'])>1) { # if the length is greater than one
echo "<title>".$row['titledate']."</title>\n"; # Display the date value
} else { # Otherwise...
echo "<title>".$row['title']."</title>\n"; # Display the title value
}
Thanks!
Craig