/    Sign up×
Community /Pin to ProfileBookmark

What is the best to insert IF statement after while ($r = mysql_fetch_array($w)) {

What is the best to insert IF statement after

[code=php]while ($r = mysql_fetch_array($w)) {[/code]

like? I would like in order that

[code=php]<comments>’.$site_adres.”news.php?id=”.$r[‘url’].'</comments>[/code]

was showed only if

[code=php]$r[“comm”] = ‘1’[/code]

Script:

[code=php]<?php header(“Content-type: application/rss+xml”); header(“Accept-Encoding: iso-8859-2″); echo ‘<?xml version=”1.0″ encoding=”iso-8859-2″ ?>’;
?>

<rss version=”2.0”>
<channel>
<title>Aktualno&#347;ci LO im. Jose Marti w Warszawie</title>
<link>http://josemarti.waw.pl</link>
<description>Szkolne aktualno&#347;ci</description>
<language>pl</language>
<managingEditor>[email protected] (Kamil Szmit)</managingEditor>
<webMaster>[email protected] (Kamil Szmit)</webMaster>
<copyright>Wszelkie prawa zastrze&#380;one. All rights reserved</copyright>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php require_once(‘mwc.php’); $w = mysql_query(“SELECT data.*, cat.ID AS cat_ID, cat.title AS cat_title, user.ID, user.name, user.email FROM $GLOBALS[news_data_tbl] data, $GLOBALS[news_cat_tbl] cat, $GLOBALS[users_tbl] user WHERE data.stat=’1′ AND data.ID2 = cat.ID AND data.user_id = user.ID ORDER BY data.date DESC”); while ($r = mysql_fetch_array($w)) {echo ‘ <item>
<title>’.$r[‘title’].'</title>
<link>’.$site_adres.”news.php?id=”.$r[‘url’].'</link>
<pubDate>’.date(“r”, $r[“date”]).'</pubDate>
<description><![CDATA[‘.str_replace(array(“../”, ‘href=”plan’, ‘href=”galery’), array($site_adres, ‘href=”‘.$site_adres.”plan”, ‘href=”‘.$site_adres.”galery”), $r[“text”]).’]]></description>
<author>’.$r[“email”].’ (‘.$r[“name”].’)</author>
<category>’.$r[“cat_title”].'</category>
<guid isPermaLink=”true”>’.$site_adres.”news.php?id=”.$r[‘url’].'</guid>
<comments>’.$site_adres.”news.php?id=”.$r[‘url’].'</comments>
</item>
‘;} ?>
</channel>
</rss>[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bokehOct 16.2007 — [code=php]while ($r = mysql_fetch_array($w))
{
if('1' === $r["comm"])
{
echo "<comments>{$site_adres}news.php?id={$r['url']}</comments>";
}
}[/code]
Also, work on making your code look nice, something you can be proud of.
Copy linkTweet thisAlerts:
@szmitekauthorOct 17.2007 — Thank you Brohen! It works (RSS feed).

Script:

[code=php]<?php header("Content-type: application/rss+xml"); header("Accept-Encoding: iso-8859-2"); echo '<?xml version="1.0" encoding="iso-8859-2" ?>';
?>

<rss version="2.0">
<channel>
<title>Aktualno&#347;ci LO im. Jose Marti w Warszawie</title>
<link>http://josemarti.waw.pl</link>
<description>Szkolne aktualno&#347;ci</description>
<language>pl</language>
<managingEditor>[email protected] (Kamil Szmit)</managingEditor>
<webMaster>[email protected] (Kamil Szmit)</webMaster>
<copyright>Wszelkie prawa zastrze&#380;one. All rights reserved</copyright>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php require_once('mwc.php'); $w = mysql_query("SELECT data.*, cat.ID AS cat_ID, cat.title AS cat_title, user.ID, user.name, user.email FROM $GLOBALS[news_data_tbl] data, $GLOBALS[news_cat_tbl] cat, $GLOBALS[users_tbl] user WHERE data.stat='1' AND data.ID2 = cat.ID AND data.user_id = user.ID ORDER BY data.date DESC"); while ($r = mysql_fetch_array($w)) {echo ' <item>
<title>'.$r['title'].'</title>
<link>'.$site_adres."news.php?id=".$r['url'].'</link>
<pubDate>'.date("r", $r["date"]).'</pubDate>
<description><![CDATA['.str_replace(array("../", 'href="plan', 'href="galery'), array($site_adres, 'href="'.$site_adres."plan", 'href="'.$site_adres."galery"), $r["text"]).']]></description>
<author>'.$r["email"].' ('.$r["name"].')</author>
<category>'.$r["cat_title"].'</category>
<guid isPermaLink="true">'.$site_adres."news.php?id=".$r['url'].'</guid>
';
if('1' === $r["comm"]){echo ' <comments>'.$site_adres.'news.php?id='.$r['url'].'</comments>
';}
echo ' </item>
';} ?>
</channel>
</rss>[/code]
Copy linkTweet thisAlerts:
@NightShift58Oct 17.2007 — Also, work on making your code look nice, something you can be proud of.[/QUOTE]
[code=php]<?php
WHILE ($r = mysql_fetch_array($w)) :
IF ('1' === $r["comm"]) :
echo "<comments>{$site_adres}news.php?id={$r['url']}</comments>";
ENDIF;
ENDWHILE;
?>[/code]
???
×

Success!

Help @szmitek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...