Jump to content

What am I doing wrong??


TFD3

Recommended Posts

I have gotten a XML feed and I put together this script to display the XML in a certain way. I am trying to use a IF statement and a $_GET statement to make only the lines show up that have the word reports in it, but its not working for some reason. Here is the script.

 

Output: http://www.alabamaweather.org/rss/reports.php?site=KAPX&type=reports

 

<center>
<?php
$site = $_GET['site'];
$type = $_GET['type'];
?>

<div class="contentmenu4">

<?php
echo "Local Storm Reports & Current Advisories from WFO $site\n";
?>
<br /><br />

<?php
require_once("rsslib.php");
echo RSS_Links("http://mesonet.agron.iastate.edu/iembot-rss/wfo/$site.xml", 1000);
        if ($type === RSS_Links)
?>

<br><br>
<div align="center"><a href="http://www.alabamaweather.org'>AlabamaStormTrackers - AlabamaWeather.org</a></div>


</div>
</center>

Link to comment
https://forums.phpfreaks.com/topic/109312-what-am-i-doing-wrong/
Share on other sites

which bit of that code is relevent to the question?

 

"not working" is a totally meaningless phrase. Define it.

 

The IF statement is not working.

I need only certain titles to show up with certain words in it, in this case that word is reports.

The titles are in blue on this page:

http://www.alabamaweather.org/rss/reports.php?site=KICT&type=reports

the &type=reports does not isolate just the titles with the word reports in it.

 

Here is the code that runs on rsslib.php, thats included in the script posted above.

 

$RSS_Content = array();

function RSS_Links($url, $size)
{
global $RSS_Content;

$page = "";

RSS_RetrieveLinks($url);
if($size > 0)
	$recents = array_slice($RSS_Content, 0, $size);

foreach($recents as $article)
{
	$type = $article["type"];
	if($type == 0) continue;
	$title = $article["title"];
	$link = $article["link"];
	$page .= "<li><a href=\"$link\" target=\"_blank\">$title</a></li>\n<br>";			
}

$page .="</li>\n";

return $page;

}

The if statement im talking about is in my first post, the only if statement in the code posted.

I just posted the second script because that is also used to display the titles, everything in that one works just fine.

 

In the first script i posted I added the

 

$type = $_GET['type'];

and

if ($type === RSS_Links)

 

After I added the above I needed to add &type=reports so I can get just the titles that have the word reports in it but its showing all titles.

 

Well,  if you'd defined "not working" in your first post ... I apologise for my ESP quotient being average.

 

before the line

if ($type === RSS_Links)

 

add

echo RSS_Links;

 

I doubt if it contains what you expect as it's an undefined constant. If it were a string it would be enclosed in quotes and if it were a variable it would be $RSS_Links.

 

What do you expect it to contain?

Well,  if you'd defined "not working" in your first post ... I apologise for my ESP quotient being average.

 

before the line

if ($type === RSS_Links)

 

add

echo RSS_Links;

 

I doubt if it contains what you expect as it's an undefined constant. If it were a string it would be enclosed in quotes and if it were a variable it would be $RSS_Links.

 

What do you expect it to contain?

 

Im not really sure how all this works because im still learning.

If there is another way, and if this makers it easier then..

 

XML Feed:

http://mesonet.agron.iastate.edu/iembot-rss/wfo/kict.xml

Needs to display:

any titles/links with the word:

reports

 

 

What im trying to do is just "cut" the storm reports out of all the other stuff that is displayed in these XML feeds.

there may be another way of doing this but I have used if statements in other script and it has always worked. I have not tried it with a XML link so I guess its a bit harder.

The XML link has nothing to do with your problem. The problem lies with "RSS_Link". As it stands, nothing has been assigned to it to give it a value.

 

I tried this just to see if this helps:

 

<?php


$xmllink = "http://mesonet.agron.iastate.edu/iembot-rss/wfo/$site.xml";


require_once("rsslib.php");
echo RSS_Links("$xmllink", 1000);
        if ($title == $xmllink)
?>

 

But nothing changed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.