adman4054 Posted April 13, 2011 Share Posted April 13, 2011 I'm trying to build an RSS feed, I have all the tables and rows identified, but I need to only pull listings with a type designated as "f" Where and how would I use: " if($listType == 'F') " In the code below, Thanks in advance! <? class RSS { public function RSS() { require_once ('pathto.../mysql_connect.php'); } public function GetFeed() { return $this->getDetails() . $this->getItems(); } private function dbConnect() { DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)); } private function getDetails() { $detailsTable = "webref_rss_details"; $this->dbConnect($detailsTable); $query = "SELECT * FROM ". $detailsTable; $result = mysql_db_query (DB_NAME, $query, LINK); while($row = mysql_fetch_array($result)) { $details = '<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>'. $row['title'] .'</title> <link>'. $row['link'] .'</link> <description>'. $row['description'] .'</description> <language>'. $row['language'] .'</language> <image> <title>'. $row['image_title'] .'</title> <url>'. $row['image_url'] .'</url> <link>'. $row['image_link'] .'</link> <width>'. $row['image_width'] .'</width> <height>'. $row['image_height'] .'</height> </image>'; } return $details; } private function getItems() { $itemsTable = "webref_rss_items"; $this->dbConnect($itemsTable); $query = "SELECT * FROM ". $itemsTable; $result = mysql_db_query (DB_NAME, $query, LINK); $items = ''; while($row = mysql_fetch_array($result)) { $items .= '<item> <title>'. $row["title"] .'</title> <link>'. $row["link"] .'</link> <description><![CDATA['. $row["description"] .']]></description> </item>'; } $items .= '</channel> </rss>'; return $items; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/233594-where-to-apply-if-statement/ Share on other sites More sharing options...
monkeytooth Posted April 13, 2011 Share Posted April 13, 2011 Since your using mySQL there is not "IF" needed.. this would be more of a mySQL related question.. what you need to do is structure your queries example from existing code posted: $query = "SELECT * FROM ". $detailsTable; Would be changed to something like.. $query = "SELECT * FROM ". $detailsTable WHERE listType = 'F'"; Quote Link to comment https://forums.phpfreaks.com/topic/233594-where-to-apply-if-statement/#findComment-1201068 Share on other sites More sharing options...
adman4054 Posted April 13, 2011 Author Share Posted April 13, 2011 Thank you Monkeytooth Since your using mySQL there is not "IF" needed.. this would be more of a mySQL related question.. what you need to do is structure your queries example from existing code posted: $query = "SELECT * FROM ". $detailsTable; Would be changed to something like.. $query = "SELECT * FROM ". $detailsTable WHERE listType = 'F'"; Quote Link to comment https://forums.phpfreaks.com/topic/233594-where-to-apply-if-statement/#findComment-1201069 Share on other sites More sharing options...
monkeytooth Posted April 13, 2011 Share Posted April 13, 2011 Correction of my Example.. $query = "SELECT * FROM ". $detailsTable ." WHERE listType = 'F'"; your welcome Quote Link to comment https://forums.phpfreaks.com/topic/233594-where-to-apply-if-statement/#findComment-1201070 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.