PHP - Filter Rss Like Internet Explorer Does
Hello...
I'm working on a webpage (http://66.119.8.164/freedownloads.php) that pulls from an rss feed (http://www.moorelife.org/rss/FreeDownloads.xml). Please keep in mind that I'm working on content, not design. It's a very long page, currently. I want to have links on a sidebar that will allow sorting and filtering, based on <category>. I got the idea from, get this, Internet Explorer's built-in rss reader. It's great. I have a section of the page populating with SimpleXMLElement (that's where the case cover images and titles are). Above that is an alphabetic listing of all those entries populated by SimpleDOM's sortedXPath. Between those two are a few category links that use ajax to overwrite the section pulled with SimpleXMLElement. Now, I don't have any idea if I'm even doing this in an intelligent manner. As a matter of fact, I'm sure it's very far away from resourceful code. It's just what I have gotten to work when other options didn't work. Now, on to the problem. The code, below, is the php file (http://66.119.8.164/include/getrss.php) that ajax uses to overwrite the original list. Code: [Select] <?php //get the category from URL $category = $_GET["category"]; $xml = "http://www.moorelife.org/rss/FreeDownloads.xml"; $xmlDoc = new DOMDocument(); $xmlDoc->load($xml); $item = $xmlDoc->getElementsByTagName('item'); for ($i=0; $i<=5; $i++) { $item_title = $item->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue; $item_category = $item->item($i)->getElementsByTagName('category')->item(0)->childNodes->item(0)->nodeValue; echo "<p>".$item_title."</p>"; echo "<p>".$item_category."</p>"; } ?> How do I only show the entries where $catagory match <category>? JJ Similar TutorialsHi All! First post here - I'm a bit of a self taught PHP junkie I'm having some issues with the following php/MySQL code. The issue is with Internet Explorer (surprise, surprise) I have setup an if statement so that the long description field in the form comes up as a text area (based on the max-length property of the mySQL field.), while the shorter fields come up as text fields. The issue is that in IE, none of the shorter fields preceding the Long Description Text Field show up - ie. the form is lacking a couple of necessary fields. Works perfectly well in Firefox. <form id="addprod" name="addprod" action="" method="get" enctype="multipart/form-data"> <?php require_once($_SERVER['DOCUMENT_ROOT'].'/resources/db/viewer_connect.php'); $table = 'products'; $fieldQuery = "SELECT * from $table"; $result = mysql_db_query($dbname,$fieldQuery) or die('<span class="body_text">Query Error: '.mysql_error().'</span>'); $i = 0; $prInfo = array('PROD_ID'=>'Product ID', 'PROD_NAME'=>'Product Name', 'PROD_DESC_SHORT'=>'Product Description (Short)', 'PROD_DESC_LONG'=>'Product Description (Long)', 'MODEL_1'=>'Model 1', 'MODEL_2'=>'Model 2', 'MODEL_3'=>'Model 3', 'MODEL_4'=>'Model 4', 'MODEL_5'=>'Model 5', 'RRP_1'=>'Model 1 RRP($)', 'RRP_2'=>'Model 2 RRP($)', 'RRP_3'=>'Model 3 RRP($)', 'RRP_4'=>'Model 4 RRP($)', 'RRP_5'=>'Model 5 RRP($)', 'PROD_IMG'=>'Main Image', 'IMAGE_2'=>'Image 2', 'IMAGE_3'=>'Image 3'); while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result, $i); if (!$meta) { echo "No information available<br />\n"; } if($meta->max_length<=256){ if($meta->name=='PROD_IMG'||$meta->name=='IMAGE_2'||$meta->name=='IMAGE_3'){ echo '<p class="body_text"><label for="'.$meta->name.'">'.$prInfo[$meta->name].':<input name="'.$meta->name.'" type="file" size="50" maxlength="'.$meta->max_length.'" /></label></p>'; } else{ echo '<p class="body_text"><label for="'.$meta->name.'">'.$prInfo[$meta->name].':<input name="'.$meta->name.'" type="text" size="50" maxlength="'.$meta->max_length.'" /></label></p>'; } } else{ echo '<p class="body_text" style="line-height:150px; vertical-align:top;"><label for="'.$meta->name.'">'.$prInfo[$meta->name].':<textarea name="'.$meta->name.'" cols="50" rows="10" /></p>'; } $i++; } mysql_free_result($result); ?> <p class="body_text"><input type="submit" value="Add New Record" /><input type="reset" value="Clear Form" /></p> </form> Any thoughts would be awesome!! Thanks in advance, Tim Hi, as usual there is a problem ONLY with one browser... IE (any version). Please check the webpage & notice the space between the Header buttons. I can't find the PROBLEM!!! Please help!! Thanks in advance.. Well, my page contains a URL like file.php?userid=1&pass=passwordhashblablabla. I try to open the page on opera, mozilla, safari, google chrome and so browsers and it works fine. I get the message that id/pw match and user has logged in successfully. However, when I go to THE SAME url on IE, i get message that id/pw do not match. URL is still the same, history is cleaned... Thanks in advance. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=318213.0 Hi, I have a problem with Internet Explorer converting spaces into underscores: The problem occurs using PHPRtfLite. When I run the script I want the file name to contain spaces, however in Internet Explorer these spaces are converted into underscores. This does not happen in ff, chrome, safari or opera. Any help on how to fix this would be much appreciated as I am stuck. Thanks. Joe p.s. Here is how the file name is created $filename = "Mysite - ".$u-ID."' (".$user_name.").rtf"; Hello everyone, I'm new here first post, but there's a weirdness in code that i need to share, First of all, I know everyone who knows PHP/MYSQL will say the same thing... Server side code cannot be broken by a browser, especially by client side coding. I agree!!! That may be the case here too, but I have encountered one of the weirdest code ever and the client side code is causing an unexpected result in PHP/MYSQL, and only in Internet Explorer. Unexplainable, and I am seeking for an answer. After hours of trouble shooting I finally targeted the the trouble code... and it's CSS, and it's affecting a MYSQL line of code in PHP... #somediv { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=''); } ... anyways let me explain how the code should run and the problem... in one page a variable passed in the URL is being captured by PHP using the $_GET method, if that variable is empty PHP runs a code which updates a MYSQL database. That works fine, and as expected, except in INTERNET EXPLORER. On that same page, a css file which is to be included with the output html to the browser contains the above line of css too. Now in every other browser that code works as expected, if the variable is NOT empty, update the database and then output the html code. In IE the database gets updated no matter what, whether the variable is empty of not. Now the its only the mysql code inside the IF statement that get affected, because for troubleshooting purposes I have put echo statements inside the code, to catch the problem, and the echo statements work as should, just not the mysql update statement. Someone care to shed some light into this mystery? Like many parents, I'm challenged with keeping my kids from browsing the evil parts of the internet. My son is 11 and my wife caught him deleting IE history the other day. The computer he uses is a Windows 8.1 laptop, and it is not Pro. How can i let him use internet explorer on his own user but keep him from tampering with any of the history ( or settings for that matter)? Is there a better solution? I found some internet history logging software online, but I didn't feel comfortable with the source, and fear it may contain viruses or other malware. I have been banging my head for quite a number of hours on this.........I am getting the below error with firefox 7 or chrome but NOT with IE Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/unlockth/public_html/motorola/insertmoto.php on line 35 Here is the code.......pls can anyone help me? <?php $userip = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $operator = $_POST['operator'] ; $imei = $_POST['imei'] ; $todayis = date("l, F j, Y, g:i a") ; @mail( "xxx@xxx.com", "ORDER SUBMISSION", $message = " $userip $message = $todayis Name: $name Email: $email Phone Model: $phone Phone Operator: $operator Phone Imei: $imei", "From: MOTOROLA SUBMISSION>"); ?> <? $id = $_POST['id']; include "/home/unlockth/password.php"; mysql_select_db("unlockth_unlocking",$db); mysql_query("INSERT INTO custdetails VALUES ('','$name','$email','$phone','$operator','$imei')"); $insertid = mysql_insert_id(); include "/home/unlockth/password.php"; mysql_select_db("unlockth_unlocking",$db); $getdata = mysql_query("SELECT * FROM motorola WHERE id=$id", $db); $row = mysql_fetch_array($getdata); $title = $row["title"]; $price_1 = $row["price_1"]; $price_2 = $row["price_2"]; $price_3 = $row["price_3"]; $imageaddr = $row["imageaddr"]; $description = $row["description"]; $keywords = $row["keywords"]; $time = $row["time"]; include '/home/unlockth/public_html/motorola/outputmotocode.php';?> This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=346255.0 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? 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 } ?> Hello Guys, I need some help here.. I want to implement a Bad word filter and not quite sure how to do it.. I am grabbing the following vars from the text fields $ad_title = filter_var($_POST['ad_title'], FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES); $ad_body = filter_var($_POST['description'], FILTER_SANITIZE_STRING,FILTER_FLAG_NO_ENCODE_QUOTES); Then its inserted into the db. I would like to run it through this function first.. Code: [Select] FUNCTION BadWordFilter(&$text, $replace){ // fill this array with the bad words you want to filter and their replacements $bads = ARRAY ( ARRAY("butt","b***"), ARRAY("poop","p***"), ARRAY("crap","c***") ); IF($replace==1) { //we are replacing $remember = $text; FOR($i=0;$i<sizeof($bads);$i++) { //go through each bad word $text = EREGI_REPLACE($bads[$i][0],$bads[$i][1],$text); //replace it } IF($remember!=$text) RETURN 1; //if there are any changes, return 1 } ELSE { //we are just checking FOR($i=0;$i<sizeof($bads);$i++) { //go through each bad word IF(EREGI($bads[$i][0],$text)) RETURN 1; //if we find any, return 1 } } } // this will replace all bad words with their replacements. $any is 1 if it found any $any = BadWordFilter($wordsToFilter,1); I really would also like to query a table for any words that match and then use a replacement like [censored] Any help would be greatly appreciated! 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 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. 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 I have some text boxes for searching the students in database also i have a drop down box for selecting student with balance amount to be paid tell me how to filter or search the list of stuents Code: [Select] <select> <option value="">All </option> <option value="">Unpaid </option> <option value="">Paid </option> </select> Hi there, I have one question about the function rand(), What if i want to have an number between 0 and 360 Without 90 to 180 so 91,92,93,94.....180 can't be the number how can i do that? btw, I know its possible through if,while,for and so on. But is there an other way to do this? 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 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 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 |