PHP - Filter Rss Titles
Hi,
I want to use an external rss in my site but the problem is that i only want to grab feeds that contain certain keywords in the title,
This is what i got so far to display the feed:
<?php $html = ""; $url = "http://www.feedsite.com/conv-rss.asp"; $xml = simplexml_load_file($url); for($i = 0; $i < 5; $i++){ $title = $xml->channel->item[$i]->title; $link = $xml->channel->item[$i]->link; $description = $xml->channel->item[$i]->description; $pubDate = $xml->channel->item[$i]->pubDate; $html .= "<a href='$link'><h3>$title</h3></a>"; $html .= "$description"; $html .= "<br />$pubDate<hr />"; } echo $html; ?>The feed is a classified jobs but i only need the jobs listed for musicians, keywords could be: bassist, singer, drummer, musician, etc.. Thanks Similar TutorialsI am using a header as an include, now I am wondering if there is a simple way, using php, of giving each page a seperate title, instead of them all having the standard title in the header? I followed this tutorial http://www.dynamicdrive.com/forums/showthread.php?t=28260. Everything is working fine but I cannot get the title on selected page to display. It will only display "Home" for the title on every page. I need this to say the correct title of selected page
I'm creating an edit page that has a many to many relationship between the banners table and the frames table. I hope I've explained everything clearly. So for example I have Quote
Frame 1 Instead of Quote
Frame 1 This is my tables banners table Quote
id | title frames table Quote
id | title | description | image banner_frame table Quote
id | banner_id | frame_id Here is my code $query = "SELECT frames.id as frameId, frames.title as frameTitle, banners.id as banner_id "; $query .= "FROM frames "; $query .= "LEFT JOIN banner_frame ON banner_frame.frame_id = frames.id "; $query .= "LEFT JOIN banners ON banners.id = banner_frame.banner_id"; $banner_frame = mysqli_query($conn, $query); confirmQuery($banner_frame); while($row = mysqli_fetch_assoc($banner_frame)) { $frame_id = $row['frameId']; $frame_title = $row['frameTitle']; $checked = ''; if ($row['banner_id'] == $banner_id) { $checked = 'checked'; } echo "<div class='form-check'>"; echo "<input type='checkbox' name='frames[]' id='frame_checkbox' value='$frame_id' $checked> "; echo "<label for='frame_checkbox'>"; echo $frame_title; echo "</label>"; echo "</div>"; } Edited September 25, 2019 by Chibi The code works but the title is repeated with each new set of data. I want the titles set up at the top and never repeating... No idea what is causing it.
$conn = new mysqli($servername, $username, $password, $dbname); $sql = "SELECT deadchar, level, class, killforumid, realm, date FROM pkdata ORDER BY deadchar DESC"; $result = $conn->query($sql); while($row = $result->fetch_assoc()) { $deadchar = $row['deadchar']; $level = $row['level']; $class = $row['class']; $killforumid = $row['killforumid']; $realm = $row['realm']; $date = $row['date']; $conn->close(); echo "<table><center><tr> <th> <font size=3 color=#070719>Victim</font> </th> <th> <font size=3 color=#070719>Level</font> </th> <th> <font size=3 color=#070719>Class</font> </th> <th> <font size=3 color=#070719>Killer</font> </th> <th> <font size=3 color=#070719>Realm</font> </th> <th> <font size=3 color=#070719>Date</font> </th> </tr></center>"; echo "<tr><center> <td><center>$deadchar</center></td> <td><center>$level</center></td> <td><center>$class</center></td> <td><center>$killforumid</center></td> <td><center>$realm</center></td> <td><center>$date</center></td> </tr>"; echo "</table>"; } ?> Hi There, I would like my webpage title to change for each sub-site that I visit say I go to player A I want the website name to say CNGHLDB-Player A and If I go to player B profile it would change to say CNGHLDB-Player B I have the names in my php script so I am assuming it shouldn't be to hard to do the coding for it, but I am not sure how to do it. <title>CNGHLDB</title> </head> <? // Connects to your Database mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); //Get PlayerID from URL $iPlayerID = $_GET["PlayerID"]; $iNationID = $_GET["NationID"]; $oPlayerInfo = mysql_query(" SELECT Players.PlayerID, Players.FirstName, Players.LastName, Players.Position, Players.Height, Players.Weight, Players.DOB, CNGHLTeams.CNGHLRights, NHLTeams.Team, Players.CNDraftYR, DraftTeam.DraftID, Players.CNDraftPOS, Countries.Nation, Players.NationID, DraftTeam.DrTeam FROM Players Left JOIN CNGHLTeams ON Players.CNGHLID=CNGHLTeams.CNGHLID Left JOIN NHLTeams ON Players.TeamsID=NHLTeams.TeamID Left JOIN Countries ON Players.NationID=Countries.NationID Left JOIN DraftTeam ON Players.DraftID=DraftTeam.DraftID WHERE Players.PlayerID=$iPlayerID ORDER BY Players.LastName; ") or die(mysql_error()); while($row = mysql_fetch_array($oPlayerInfo)) { Print "<body>"; ECHO "<div align='center'>"; ECHO "<table width='496' border='0'>"; ECHO "<tr>"; ECHO "<td width='148'><div align='center'><a href=\"http://www.cnghl.org/cnghldb/index.php\"><strong>SEARCH PLAYERS</strong></a></div></td>"; ECHO "<td width='152'><div align='center'><a href=\"http://www.cnghl.org/cnghldb/goaliesearch.php\"><strong>SEARCH GOALIES</strong></a></div></td>"; ECHO "<td width='182'><div align='center'><strong><a href=\"http://www.cnghl.biz/history/league.html\">FRANCHISE HISTORY</a></strong></div></td>"; ECHO "</tr> </table> </div> <p align='center'> </p> <p>"; Print "<center> </p> <div align='center'> <table width='700' border='0'> </center>"; Print "<tr>"; Print "<td colspan='3'><h1>".$row['FirstName']." ".$row['LastName']." <img src=\"http://www.cnghl.org/cnghldb/nation/".$row['NationID'].".gif\"></h1></td>"; Print "</tr>"; Print "<tr>"; Print "<td width='300' height='26'><strong>Birthdate: </strong>".$row['DOB']."</td>"; $DOB = $row[DOB]; //dd.mm.yyyy $user_date = new DateTime($DOB); $curr_date = new DateTime(); $age_cal = $curr_date->diff($user_date); Print "<td width='525'><strong>Age: </strong>".$age_cal->y;"</td>"; Print "<td style='vertical-align:top;'width='275' rowspan='10'><div align='center'><img src=\"http://www.cnghl.org/cnghldb/images/".$iPlayerID.".jpg\">"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Nation: </strong>".$row['Nation']."</td>"; Print "<td><strong>CNGHL Team: </strong>".$row['CNGHLRights']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Position: </strong>".$row['Position']. "</td>"; Print "<td><strong>Weight: </strong>".$row['Weight']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Height: </strong>".$row['Height']. "</td>"; Print "<td><strong>NHL Team: </strong>".$row['Team']. "</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Draft Year: </strong>".$row['CNDraftYR']."</td>"; Print "<td><strong>Draft Position: </strong>".$row['CNDraftPOS']."</td>"; Print "</tr>"; Print "<tr>"; Print "<td><strong>Drafted By: </strong>".$row['DrTeam']."</td>"; Print "<td> </td>"; Print "</tr>"; Print " <tr> <td height='179' colspan='2'> </td> </tr> The coding that pulls there names that I would want to use is Firstname and Lastname or I have the simpler full name that include both first and last names. Thanks for your help! Edited by mac_gyver, 10 June 2014 - 03:36 AM. code tags around code please Hi peeps, was wondering if anyone could help, i have decided I want to put page titles in to my website at the moment i have a static title which is the business name and slogan, what I want is business name - slogan - page title (E.G home) my title is set in a header.php file which is then included in all pages. any ideas? Hi all Recently designed a site using includes, but only realised when I'd almost finished the project that because the (e.g.) include("includes/header.html"); had the <head> information (titles, meta description, etc) every single page included the same information (by the way hope this makes sense) A way I thought of getting around this was to store each pages title and meta description in a database or in for example or maybe in a variables.php file. But I'm not sure whether this is the best way. I'm not a PHP expert so simple explainations would be very much appriciated. Look forward to hearing from you all. Adi <ul> <!-- List the rest of the articles found in the category --> <?php else : ?> <li class="otherrecentmain"><span class="title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span> <span class="meta"></span> </li> <?php endif; ?> <?php endwhile; ?> <!-- END --> </ul> For some reason, its stuck on displaying 9 articles but I want to be able to control how many I want. I may want to choose 17 or whatever etc, not sure how to add it into the php. I feel like a moron asking this question as it seems to be one of the most common things done with php but I cannot find a tutorial (probably because I don't know the correct wording to search under) on this specific thing.. Anyhow. I'm spitting out a list of the Titles of my test table like so (and its working as expected): <?php $posting_sql = "SELECT * FROM postings"; $posting_results = (mysqli_query($cxn, $posting_sql)) or die("Was not able to grab the Postings!"); while($posting_row = mysqli_fetch_array($posting_results)) { echo "<li><a href='posting_details.php'>$posting_row[title]</a></li>"; } ?> Now as you can see: <a href='posting_details.php'> I am calling a new page, and that page contains this: <h2><?php echo "$posting_row[title]"; ?></h2> <p><?php echo "$posting_row[description]"; ?></p> It's no surprise it's not working (with many variations etc), but I am only familiar with using <form> GET or POST, and these of course are not form elements, so I cant seem to call them the same way. My suspicion (and from the research data I could find) is that I need to pass values in my link: <a href='posting_details.php'> ... I could not get it to work, but I was trying variations like: <a href='posting_details.php?get[title&get[description]]'> but it seems like I am screwing things up even more by doing this.. Anyhow. If anyone could show me a tutorial that covers this specifically or some suggestions on the best approach to this would be much appreciated.. Hi. I was hoping someone could tell me whether this is possible and if so how I could go about doing it preferably with a tutorial as im pretty new to programming. I have a database that will contain 100's of records. I want users to be able to select filter parameters on this data by both text and checkboxes with it automatically updating the results (hopefully without page reload). I managed this so far using this Jquery filter script: http://www.picnet.com.au/picnet-table-filter.html. As this will table will have so many rows however I think it would take ages to load so instead I would like to paginate the table but still allow filters applied to affect all records not just the ones displayed on the current page. Any ideas on how i could do this? Thanks in advance for your help. I have a MySql table full of records. id owner car location on my page i have these results in a table i want to set a filter up so the table will only show cars from eg location England. at the minute its just set to show cars that owner has but i want a location filter any help HI all, Yesterday i read quite alot about htmlentities() htmlspecialchars() mysql_real_escape_string But today i stumbled upon filter() (http://www.w3schools.com/php/php_filter.asp). Does anyone know if this is also a good way to sanitize and may even be an alternative for the other functions? OR is it something completly different? I am still a novice with this so please enlighten me : ) TY Hey, I have a word filter which is dectecting strings that are only embedded in words. Which i don't want it to do. For example: If i want to filter "FR" and some one puts france - it flags it because france contains FR. How do i make it only look for "FR" on its own seperated from a word instead of it flagging nearly all words with the two letters together? Heres my filter: $text = 'testing'; //this should not return 1 // fill this array with the bad words you want to filter and their replacements $bads = array ("test"); foreach($bads as $key => $search_needle) { if(stristr($text, $search_needle) == TRUE) { return(1); break; } } Hey guys i am using a global filter on my $_POST function filter($str){return htmlentities($str, ENT_QUOTES);} $_POST = array_map('filter', $_POST); It helps me encode the stuff into the database. It works great on all my fields exept my arrays ... Ex: fields like this <input type="text" name="name[]" size="20"> breaks Any sugestions on gething this global filter working? Hello, I have a client with a "contact us" form who has recently been receiving a lot of spam emails from the form. I already have a session set in place so the form is only active one time. I am now creating a filter for the message to look for things like a url or bb style codes etc. What I've got seems to be working but would like your thoughts on maybe a better way of doing it or if you see something I may be missing. IF an offending text is detected the ip address is sent to me and I can block ip from the site. If the message passes it is sent to the client. This is the related code. Code: [Select] <?php $themessage=str_replace("\r",'<br>',$_POST['message']); $badwords=array("[", "url", "http", "link", ".com", ".net", ".org", ".biz", "<"); $o=0; foreach($badwords as $key2 => $value2){ $pos = strpos($themessage, $value2); if ($pos==0) { } else{ $o=$o+1; } } if ($o==0) { //compose and send email to client } else{ $useraddress=$_SERVER['REMOTE_ADDR']; //compose and send email to me containing offending address } ?> Hi,
I'm trying to make a program that filters data out of a website. Now I've got a problem.
For example, I've this line:
<td class="maintxt" width="200"><a href="profile.php?x=Stranger">Stranger</a></td><td class="maintxt" width="200">Godfather (96.76%)</td><td class="maintxt" width="200"><i><a href="clanprofile.php?x=Ettertjes">Ettertjes</a></i></td>Form this line I want to set the word "Stranger" in a variable, and do the same for the word "Godfather". What is the best method to do this? Thanks in advance, iRoot121 Hi ! I have an 2d array like this: column 1 column 2 column 3 $data[0][0] $data[0][1] $data[0][2] $data[0][0] RDR -1.3 0.001 $data[1][0] RQR 0.4 0.01 $data[2][0] DDR 1 0.00004 and more... Now i need to filter this data. I only need the rows with column 3 < 0.01 AND column2 > 1 or column 2 < -1 . I have this, but it doesn't work: $teller = 0; for($i = 0; $aantal>$i; $i++) { if($data[$i][2]<=0.01) { $p[$teller][0] = $data[$i][0]; $p[$teller][1] = $data[$i][1]; $p[$teller][2] = $data[$i][2]; $teller++; } } $teller2 = 0; for($i = 0; $teller>$i; $i++) { if($p[$i][1] < -1 || $p[$i][1] > 1 ) { #als de p value kleiner is dan 0.01 dan alles kopieren in een nieuwe array $r[$teller2][0] = $p[$i][0]; $r[$teller2][1] = $p[$i][1]; $r[$teller2][2] = $p[$i][2]; $teller2++; } } Can you help me? I'm having some problems with a piece of software I use on a clients website. There is a "related items" function module available, with this module you can filter to show items from the same category OR in the same city. But now my client want's the module to show only items that are located in the same category AND the same city.
My PHP knowledge is just not good enough to solve this myself, that's why I ask for advice here. I already defined the lines of code that manage the filter, but I don't know how to make this from an "OR" filter to an "AND" filter. Can someone help me with this?
// Join over prop mid table if getting related by category if($search_cat) { $cats = ipropertyHTML::getAvailableCats($property->id); if($cats) { $searchwhere[] = 'pm.cat_id IN ('.implode(',', $cats).')'; } } // Filter by city. if($property->city && $search_city) $searchwhere[] = 'p.city = '.$db->Quote($property->city); if( count($searchwhere)) $query->where('('.implode(' OR ', $searchwhere).')');I have attached the complete file in case that gives a better insight in the filter function. Best regards, Niels Attached Files helper.php 4.79KB 1 downloads so I'm running a query on a database to get address's $address = $row['address']; it returns "1234 Test St" I want to be able to sort all the records by the street name without the numbers How do I know if Filter extension is on with my webhost? Or does it always work with PHP5? If I cannot use it, can someone recommend a good regex to validate EMAIL addresses?? Thanks, Debbie |