Filtering XML Results
I'm in the process of creating a page that displays multiple lines of inventory for a bunch of products (let's call them 'widgets'). The widgets are listed in XML format (they'll end up being pulled from a MySQL DB eventually). Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
DVD Id Is Incorrect After Filtering Results
I am making a basic DVD shop and after having produced code which displays a list of DVDs from my database, I implemented a search facility which enables the user to search by title, director or actor. The user can also browse the DVDs by genre. However, when the DVDs are filtered, the id that is used to select a DVD and add it to the basket is incorrect as they are output in a sequential manner and so the DVD placed into the basket will be that matching the id. Here is the loop that outputs the DVDs (I have a DVDID field as you probably have guessed): if (mysql_num_rows ($getdvds_query)) { for ($id = 0; $dvd[] = mysql_fetch_assoc ($getdvds_query); $id++) { echo "<tr> "; echo "<td>{$dvd[$id][title]}</td> "; echo "<td>{$dvd[$id][duration]}</td> "; echo "<td>{$dvd[$id][rel]}</td> "; echo "<td>{$dvd[$id][descr]}</td> "; echo "<td>{$dvd[$id][genre]}</td> "; echo "<td>{$dvd[$id][stock]}</td> "; echo "<td>{$dvd[$id][price]}</td> "; echo "<td><a href="$PHP_SELF?add=$id">add to basket</a></td>"; echo "</tr> "; } } Here is the code that adds to the basket variable: if (isset ($_GET['add'])) $_SESSION['trolley'][] = $_GET['add']; else if ($_GET['op'] === 'clear') $_SESSION['trolley'] = "";
Filtering Results With Php Query
This code works, but I don't know how to filter the results to where only one person is displayed..it displays all records with similar address or state or city, I would like to know how to make it display only one person when multiple search fields are entered. I'm using PHP5, and I have searched the forums but I'm not sure exactly if I found what I'm looking for...I don't know much about php or mysql. Code:
Filtering Results By DATE Value In Database
I have this code in my page for displaying some data from a database, sorted by date. i had posted a messed up version of this a while ago but I couldnt get it working even after a few suggestions. PHP Code:
Filtering HTML With PHP
I am using PHP to set up a message board which interfaces with a mySQL database. I am trying to filter malicious HTML code that users would try to leave on the message board. I want to strip all HTML tags except the <A HREF> tag.
Filtering Out Bad Input
I am currently building a website, with a built in news and comment, so far i know have been able to filter out thing such as swear words, however is it possible to filter of say f someone held down the ===================================================== ============= key Is there a way to prevent this or will i have to have some sort of statement that counts how many times the = or other char is grouped together?
Filtering RSS Content
I need to install an rss aggregator on a website. The catch is that it should only pull in items from feeds which contain certain keywords. Any idea how this can be done or if such a content managing software already exists?
Dirty Filtering
does any one has a list of dirty words, do not post in this forum, but show me url. PHP Code:
Username Filtering
I'm having problems with regular expressions. How could i check if a variable has only letters and numbers in it?
Price Filtering
I am having an issue with filtering price from a form variable so maybe someone can tell me how I'm screwing this up. I have a search page that has 3 criterias for search - category 'cat', price 'price' and location 'area'. I am using Dreamweaver 8 for this project. I can create the query for both cat and area for the double filter, but when i get to price it removes all the records from view. I removed the 2 working queries and am now focusing on the 'price' query. My SQL looks something like this: Code:
Filtering Data
I've got a question which is more aimed at drumming up some opinions/starting a discussion then looking for a "right answer". I am writing an application and I wanted to hear some suggestions on how to handle the filtering of data from the user. The data is all coming in through one class where it is then passed as arguments to methods down the hierarchy, so it seems to make sense to do the checking at that top point. However what isn't as clear is whether the regular expressions (or some alternative) used should be exclusively set by the top level class. For instance I see that Cake (a framework) has a protected _validation array which Models can set with their own regex. I am not a huge fan of this approach because it leaves the array protected, and because it may be responsibility that goes past the role of the class. In fact I'd prefer a method which didn't rely so heavily on regex in the first place as I find regex hard to maintain. So what solutions have you come up with to handle input? I'm looking for suggestions which are flexible enough to accomodate unforseen changes in security, but simple enough to be implemented in a single class (or a single method). To kick this off here's my current solution (somewhat described above) if (!is_array($this->_validation)) throw new Exception("Unable to validate data bad validation hash found"); $result = array(); foreach ($arguments as $key => $value) { $pattern = $this->_validation[$key]; if ($pattern == null) throw new Exception("The submitted data has no corresponding pattern and can not be evaluated"); if (!preg_match($pattern, $value)) throw new Exception("The submitted data was invalid"); $result[$key] = $value; } return $result;
IP Filtering By Country
Does anyone know of some good ways to filter traffic by country? I can only monetize US, UK, and Canada traffic, but must send them to a different thing for each country. All other countries I would like to send somewhere else.
Filtering Of Characters
Does filtering of certain characters make a search engine more efficient? Speical characters such as ~!@#$%^&*()_+
Error Filtering Bad Language
I have a dynamic shout box service, and I need to filter bad language, so i wrote a function on how it should work. PHP Code:
Filtering Out Keywords In A Search!
I have about 1100 movie titles in a database. I am trying to do a simple search engine and have seperated each keyword using the following code: $q = $_GET['q']; if ($q) { $q = strtolower($q); $k = split(" ", $q); $num_keywords = count($k); for ($i=0; $i<$num_keywords; $i++) { if ($i) { $search_string .= "OR moviename LIKE '%" . $k[$i] . "%' "; } else { $search_string .= "moviename LIKE '%" . $k[$i] . "%' "; } } end for $and .= "WHERE ($search_string) "; } //end if $querycount = "SELECT * FROM titles $and"; rest of code... This works ok, but if I type something in like 'The Killer' it fetches everything with the word 'the' as well. I have put the words into an array that I want to filter out. $skipwords = array("the", "of", "and"); etc Can I use that to filter out the words? I`ve been playing around with the in_array() function, but can`t seem to get it to work like I want it to.
Audio Filtering Via PHP, Program
I have been tasked with trying to find a way to complete this project... I'm not sure if it is possible, but hopefully you guys can provide some insight... I need to create a web application that will allow a visitor to record their voice into an audio file, then apply different filters/effects to it (like robot, lady, etc.), and send it to a friend. I haven't the slightest clue where to begin on doing something such as this. I searched google for a similar functionality, and have come up empty handed. Has anyone seen anything like this done, or an application that would do something like this, PHP or otherwise?
Filtering A Db With A Start And End Date
I have a MySQL table with a datetime field. I need to make a PHP script that will take all rows whose datetime field falls within that of a user-specified begin and end time. Anyone have a code snippet to do that?
HTTP Filtering With PHP & Apache ?
I am looking for a full example how I can achieve an http output filtering with php on an apache 2 server. I found some hints that the apache server supports to isntall and conifugrate such filters http://httpd.apache.org/docs/2.0/mo...addoutputfilter But I didn't found an example which is related to PHP. I like to achieve for my shop using a template mechanism based on xml & xsl with PHP. My idea is currently to use an output filter which does the xsl transformation. If anybody knows a tutorial or even some applicable frameworks in this area please post me here the links.
User Input Filtering
I have a comments system. In this comment system, people can enter certain strings, and it will break my page layout. Such as repeated characters with no spaces. It will just blow the table way out of proportion and completely ruin my layout. How can I break their input up if such a thing happens? Also, how can you number an array of data that is being withdrawn from the database DESC? Such as.. Quote1. itemnumber1 2. itemnumber2 3. itemnumber3 4. itemnumber4
Filtering Message From The Database
i have a page where people can send in MMS pictures and they get uploaded and displayed on my page, they need to type a keyword in the MMS like "sendmms" to make it work. if they also write "sendmms hey look at me" it also works since "sendmms" was at the beginning of the message and "sendmms hey look at me" get's added to the row "message" in my database. the pictures get an ID in the database and saved with the same ID on the server. so under each picture sent in i wanted to add the comment they added after the "senmms" part. so in short, how do i make it filter out "sendmms" and only display "hey look at me" ? and if the Page ID is let's say 13 it should display the "messsage" column for the ID in the database that has the same ID as the page ID is.
Filtering User Input...
I want to take text that a user inputs and store it into a variable. That's the easy part. I have and array of 30 elements that I want to store the inputted text into. So.. here's an example... - I want a user to enter text. - I'll store it into a variable like $inputText. - I want to split the text from $inputText into 30 equal sections and store each section into an element in the variable. - I don't care if the words get separated during the filter, as long as the whitespaces stay where they are. Could anyone give me some tips to help me get started or point me towards a tutorial or something?
Filtering A Recordset With A Session Variable
I have two forms, the Form1 and the Form2. One of the answers in the Form1 is saved in a session variable SesVar1. In the Form2 there is a dynamic table build with a recordset. I need to filter the recordset of the Form2 with SesVar1. I tryied to do this using a variable in the recordset window of dreamweaver, writing #SesVar1# in the run-time value of the variables for the recordset, but it didn't work. Please HELP me out with this one. How can I filter that recordset using the value of a session variable? or the Form1's answer?
Image File Upload Filtering
I have made a file uploader, I also made a filter, I can't make a good filter for jpeg files, but i can filter gif, can you advice, thanks if ($_FILES["file".]["type"] == "image/gif") bla bla bla
Filtering Selection In Multiple Drop Down Boxes
I want to allow a user to conduct a search on a database using multiple drop down boxes. On the first page they will have a drop box filled with records from field A. Once they select which one they want, a second drop down box will then appear with records from field B which are present for field A (a filter). What I want though is that the first dwon down box still appears on the second page, but shows the record that the user selected. What is happening now is that when the second page comes up, the first box shows the default selection rather than the selection that the user chose. My code for the drop down boxes is: PHP Code:
Filtering The Elements Of A Multi-dimensional Array
I would like to be able to filter every element of a multi-dimensional array using htmlspecialchars() and to retain the structure of the array. I can't see how to do this when I don't know how many dimensions the array has.
Dynamic Recursive/nested Foreach (part Deux) With Filtering
I originally wanted to figure a method to better implement a nested foreach to calculate all the permutations held within an array. After posting the topic and getting great responses an elegant solution was found. I then increased the difficulty by requesting that we also include a method to "filter" or "skip" certain values during permutation calculation. The original solution finder quickly came back with yet another code snippet listed below which acomplished the request...it was mere childs play it seems for them (sasa). I marked the topic solved as the original question had been solved. I am creating this new thread as I am once again adding an additional layer of difficulty. The final previous solution is listed first as a reference, followed by the new and more complex problem underneath that one. My attempts to shunt in the functionality have all failed I think due to the recursive nature...any takers? Code:
Search Brings Back Different Results Or Sometimes No Results
The problem Iv got is that when searching the site - it brings back different results or sometimes no results. For example: "i026", "i 026" and "026" do not bring back results for "I-026" which is the correct model number. Any ideas on how to make it search more variations or of a "Did you mean... I-026" script?
Search Results ($num_rows) Does Not Match $search Results (PHP,MySQL)?
For example, when I do a database search for a term I get 2 results but the $num_rows says there are 3 results. I suspect it's because there are similar keywords within different search fields of the SQL statement. But I am stumped as to how I can change this. Any Suggestions? the code:
How To Add A <br> After 3 Results?
I am wondering if anyone could help me solve this issue. I am using a foreach loop and i would like to add a line break after three records then repeat the process. Example: foreach($array as $v){ echo $v.' ';} In that example, it will display ( apples oranges banana pumpkin turnips pineapple beer pepsi) How do i get it to display: apples oranges banana pumpkin turnips pineapple beer pepsi etc.... Notice above that after each three results the next three are placed on a new line. How can I accomplish that with my loop.
Getting Results Twice?
I am having a small problem. I have a small script which gets a METAR feed, processes it and then displays the weather information. The problem is that it will accept 1 weather station as an input variable. How can I run this script TWICE within the same execution, while getting 2 results, using 2 different weather stations? The main file uses this to execute the functions which are on another separate file: Code:
Splitting Up Results
I have a large database and would like to split the results into 20 per page and with arrows to go to the next page and numbers to skip pages. But I'm not sure how to do it. I know I've seen an article on how to do this somewhere, anyone know one about this?
Grabbing Only First Var From Results
I'm working on a calendar program that I inherited from a sick Webmaster somewhere in the world. Below is part of the code that chooses and compares dates to print on the calendar. The part in bold is what I think is going to be the key to solving my problem, I just don't know how to go about it. The 'dates' column for a record in the 'programs' look like this: &62&74&84&90, etc. Each number represents a date with more details in the 'dates' table. Echoing out $datenum will give one number like ཻ'. The problem is I want only first date and to ignore the rest per record. The SQL looks like this. Is it possible to only get the first search result of date per record? foreach ($chosen_dates as $c) { if ($c['day'] == $day_num) { if ($section == false) { // This runs for printing courses and not programs $coursenum = $c['coursenum']; $name = mysql_query("SELECT name FROM courses WHERE keyword='$coursenum'"); $name_row = mysql_fetch_object($name); // if there are courses for this $day_num print "<p><a href='course.php?index=".$c['coursenum']."' "; print "title='".$c['stime']."-".$c['etime']." ".$c['section']."'>".$name_row->name."</a></p> "; } else { // This runs to print programs and not courses. $datenum = $c['datenum']; echo "Datenum=$datenum"; $date_search = mysql_query("SELECT num, dates, category FROM programs WHERE dates REGEXP '&$datenum&'"); $date_found = mysql_num_rows($date_search); //echo "Number of dates found = ".$date_found; if ($date_found > 0) { while($row = mysql_fetch_object($date_search)) { //echo $c['section'] ." "; //echo "cat= ". $row->num; foreach($isPrinted as $printed){ if(!in_array(array('section'=>$c['section'], 'courseNum'=>$row->num), $isPrinted)){ print "<p><a href='program.php?index=".$row->num."' "; print "title='".$c['stime']."-".$c['etime']." ".$c['section']."'>".$row->category."</a></p> "; $isPrinted[] = array('section'=>$c['section'], 'courseNum'=>$row->num); break; } } }... Is there such thing as maybe using a LIMIT with this kind of SQL statement? The one above is:SELECT num, dates, category FROM programs WHERE dates REGEXP '&$datenum& Could you use something to the effect of: SELECT num, dates, category FROM programs WHERE dates REGEXP '&$datenum& LIMIT 1?
Listing Results From DB
Anyway I have a wee problem: what I have is a javascript popup with two values passed through: PHP Code:
Results Into A Matrix Using Php?
I've been trying to work out how to insert results from a database query into a two-dimensional matrix using php. We used a star schema for our datawarehouse. Thus we have a price fact table and we need to perform aggregate functions on this table. This part is relatively simple. I've managed to connect to the oracle database and retrieve the data but only display the results in a normal table. What I'd like to do is display the results in a matrix so that I can avoid repeating fields. For instance if there are three variables: Code:
Checkboxes And Sql Row Results
I am trying to place a checkbox beside each row that is inputed into the database. Now this is how I diplay the rows: print "<br><br>There are $num_rows records.<P>"; print "<table width=500 border=0> "; while ($get_info = mysql_fetch_row($result)) { print "<tr> "; foreach ($get_info as $field) print " <td><font face=arial size=1/>$field</font></td> "; print "</tr> "; How would I go about attaching this: <input type="checkbox" value="..." name="..."> to the side of each displayed row? Also, how would I assign the row id to the checkbox so that once the box is check and the action initiated the row would be deleted?
Returning Results With An '
I am using this script $mresult = mysql_query("SELECT DISTINCT game FROM vids order by id desc limit 50", $link) or die ("query 1: " . mysql_error()); while ($mrow = mysql_fetch_array($mresult)) { $count = mysql_result(mysql_query("SELECT COUNT(*) FROM vids where game = '$mrow[game]'"), 0); } but for any $mrow[game] that has an ' in it a 0 is returned, how do I fix this?
Getting Bad Results From Fsocketopen
If I send this to the server: POST /errors/index.htm HTTP/1.1 Host: www.publicdomainsoftware.org Content-Type: application/x-www-form-urlencoded Content-Length: 1200 %3C%2Fdiv%3E Why do I get this back: HTTP/1.1 400 Bad Request Date: Fri, 12 May 2006 02:37:43 GMT Server: Apache/2.0.46 (Red Hat) Content-Length: 302 Connection: close Content-Type: text/html; charset=iso-8859-1 Bad Request Your browser sent a request that this server could not understand. Apache/2.0.46 (Red Hat) Server at default Port 80
Sorting XML Results
The following code parses an XML file and displays the results. The function resultSort is meant to sort the results by price from highest to lowest. Unfortunately, it's not sorting correctly in all cases. I think this may be due to the prices being in euros. Right now, this is how it outputs the results: 1 208,00 2 148,00 412,00 638,00 942,00 This is how it should look: 2 148,00 1 208,00 942,00 638,00 412,00 Here's the code: PHP Code:
PHP - Sending Results
I am looking for a simple form Processor that will send the results to a defined user, but at the same time send these same results to the user that filled it out. This sounds simple enough I realized, but to be honest I can't seem to find anything that will easily allow me to do this and use my own HTML based inputs at the same time.
Sorting Results
I hava a table with a primary key cod_topico and I'd sort my results. I do this, ok? $query='SELECT * from topico order by cod_topico asc' ; But I would not sorting asc, How I sort a non-asc form? What is the oposite of asc?
Percentage Of Results
I have a table with various colums that I would like to display some stastisics. For example on colum is Gender. It holds either Male or Female. How can I output the percentage of each? ie... Female = 80% Male = 20%
Saving Php Results
I have an html code which contains callings to a php script which generates JPEG images via GD library. When I select 'save as' in any browser two options are given (.html or .txt) but none of them allows to save the page as it is shown in the browser (with images). Where images should be there are only empty links....Does anyone have an idea about it?
Looping Results...
I'm writing a simple display page for a bunch of info from a realestate database as an exercise. I've successfully queried and displayed the information in tables, but I want it to keep pulling information from the tables until there are no more left. What i've got only pulls one entry. Code:
Getting Too Many Results From A Query!
This is very peculiar -- for some reason, I'm getting 6-8 results from each of these queries, although only one listing matches. I have a pair of forms on one page: <FORM> Search for lastname: ____________ [Submit] </FORM> <FORM> Search for email: ________________ [Submit] </FORM> This goes to a searchresults.php page: if ($searchname !== "") { $query="SELECT artistID,firstname,lastname,email,city,state,count ry from artists WHERE lastname='$searchname'"; $result=mysql_query($query) or die(mysql_error("Could not execute query.")); while($row = mysql_fetch_array($result)) { $alt_artistID = $row['artistID']; $alt_firstname = $row['firstname']; $alt_lastname= $row['lastname']; $alt_email = $row['email']; $alt_city = $row['city']; $alt_state = $row['state']; $alt_country = $row['country']; echo "<CENTER><HR>".$alt_artistID."<BR>" .$alt_firstname." ".$alt_lastname."</A><BR>" .$alt_email."<BR>" .$alt_city.", ".$alt_state." ".$alt_country."<BR> <A HREF=delete.php?aritstID=".$alt_artistID.">DELETE THIS LISTING?</A><BR></CENTER>"; } } The second section is identical except for: if ($searchemail !== "") { $query="SELECT artistID,firstname,lastname,email,city,state,count ry from artists WHERE email='$searchemail'"; etc... } I don't understand why I would get 6-8 records when you can look at them and see that all but one clearly do not match...?
Paging Through Results
Does anyone have or know of a nice PHP class or code to page through a set of results drawn from mysql? ie to display the list of results in 'pagefuls' with a nav bar like: Code: [1] [2] >3< [4] [5] where Ɖ' is the current page, and the other numbers are links to the other pages...? I know this has been covered a few times on this forum, but I can't for the life of me find any of the threads searching on 'pager' or 'pagination'.
Confusing >> Results
Using >> normally shifts bits to the right x number of times, where x is specified by the programmer. As an example, 0x40000000 >> 8 yields 0x00400000. This makes me wonder... why doesn't the same thing happen with 0x80000000 >> 8? The number it yields is 0xff800000 - not 0x00800000. The following script better demonstrates this: <? echo sprintf('%08x',0x40000000 >> 8)." "; echo sprintf('%08x',0x80000000 >> 8); ?>
Sorting Results
What I need to do is from the query I send sort the results by ID numbers from highest to lowest, because the highest number is the most recent news post I would like this to be printed first and then the lower the ID number the further down the post goes. Am I making sense? PHP Code:
OCI - Double Results?
to work with the example for OCI... and the $row returns 2 values, the same twice, but my query only have one... code below. $query = 'select distinct(something) from a.b' $stid = oci_parse($connX, $query); if (!$stid) { $e = oci_error($connX); print htmlentities($e['message']); exit; } $r = oci_execute($stid, OCI_DEFAULT); if (!$r) { $e = oci_error($stid); echo htmlentities($e['message']); exit; } print '<table border="1">' while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) { print '<tr>' print "<td>".(count($row))."</td>"; foreach ($row as $item) { print '<td>'.$item.'</td>' } print '</tr>' } print '</table>' oci_close($connX);
Numeric Results
I have a mysql quote database and a php page that calls the results...everything is fine except for when I get the results back there are too may 0's on the ends of my numbers ie 220.45000000 and I want it to show 220.45 Can someone have a look at my code and maybe alter it to produce the results I want, I have been at this know for 3 days and because I am a newbie I am finding it difficult.. Code:
|