Hi everyone. I’m relatively new to PHP and am working on this page http://www.aguivera.com/form.php.
I need to ingest RSS for certain weather warnings and I’ve been able to do it and sort by a specific type of warning. What I’m trying to do now is show a message when there is no data that matches the specific weather warning to appear when someone selects their state.
Currently I do get a message but it keeps looping the amount of times set in my RSS $limit.
This is my code. I know it’s not pretty but I’m more interested in trying to get this to work.
Any guidance or direction would be greatly associated.
my code:
[php]
--Select State-- Alabama Alaska AR <?php $state = new DOMDocument(); if(isset($_POST["state"])){ $state->load($_POST["state"]); $feed = array(); foreach ($state->getElementsByTagName('entry') as $node) { $item = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('summary')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('id')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('published')->item(0)->nodeValue, 'type' => $node->getElementsByTagName('event')->item(0)->nodeValue, ); array_push($feed, $item);} $limit =10; for($x=0;$x<$limit;$x++) { $title = str_replace(' & ', ' & ', $feed[$x]['title']); $link = $feed[$x]['link']; $description = $feed[$x]['desc']; $category = $feed[$x]['type']; $date = date('l F d, Y', strtotime($feed[$x]['date'])); if($category == 'Flood Warning') { echo ''.$title.'
';
echo 'Posted on '.$date.'
'.$description.'
'; echo 'Type of event: '.$category.'
'; } else { echo "no warning"; } } } ?>[/php]