Simple Filter Of Database With $_GET And Select SQL
I need help with my logic statement with a simple search engine on a MySQL table. I have three form text input fields named f_name, l_name and dept. I am using the GET method to gather data the user enters in each input field.
So far I have been able to build a check to see that the submit has been clicked but I am having trouble with assembling the SQL statement because I need for the search engine to be able to filter the results based on the information provided in 1-3 of the fields.
I could use if statements with some and clauses but that would mean that I would have to account for each combination. Something like
If(($_GET[‘f_name’] != “”) || ($_GET[‘l_name’] !=) || ($_GET[‘dept] !=)){
$sql = "SELECT * FROM facform WHERE f_name LIKE '$_GET[f_name]', l_name LIKE '$_GET[‘l_name]', dept LIKE '$_GET[dept]' ”;}
The problem with this is that I would have to get every combination and it’s not very scalable. How can I create this SQL statement dynamically? Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Simple SELECT Statement
I have a dbase with some gigs that has a date field. The SELECT statement currently says... QuoteSELECT * FROM `Gigs` ORDER BY `Eventdate` ASC LIMIT 3 which works fine but I also want the statement to only show gigs that havent happened yet or that are > than today's day. I tried WHERE Evevntdate > CURRENT_DATE or something along those lines but so far havent got it to work.
Begginer's Simple PHP Select Statment
my basic table connection syntaxt using PHP. I call the php from a web browser url_name_goes_here/test.php. The database name is tennis and the user name is tennis. If I type the commands directly from the MySQL> mode, my access works fine (see example 1 below). But when I try to access the table from PHP, I have a syntaxt problem (see example 2 below). Can anyone please type up the correct PHP syntaxt for me? The 3rd example works but I don't know how to translate that into a select statement for the table. Finally, after I get it working, how do I keep my password out of sight? if I forgot to put an index file in the directory, wouldln't all of the files be visible from a surfer's browser? ...
Simple - UD Function With Select / Option
As you might guess I am completely new to this language. Maybe I get some help here. I try to execute a user defined funciton from a select option in a document to read a file into an array without using a submit button or anything else. like this: <select name="sel[]" onchange="<?php ReadFile(DependingOnValue);<?" > <option value="1"> 1st Quarter </option> <option value="2"> 2nd Quarter </option> <option value="3"> 3rd Quarter </option> </select> I know I could use Javascript instead. But I am sure there is an easy way doing in PHP.
Simple(ish) Php/database Script
Ive just bought a collection of articles, im looking for a script that will display them with an option to choose the section, ideally also an admin panel: the database ive bought is games related so im looking for something that will be able to split them up into sections eg: nintendo, sony, MS etc and possibly as an additional extra an admin panel to add sections in the future if more computer companies come in to play such as apple. As i said preferably a script already mad would be ideal, however i would consider paying for someone to create this but im short on money at the minute which is why id prefer a pre made script.
Simple Database Update Problem
I'm getting the error "Could not complete update of database". It looks like my updating is going wrong. Can someone please check for me and see whats going wrong because i cant seem to find it. PHP Code:
Simple A-Z Link List For Searching Mysql Database
I'm trying to set-up a simple A-Z list so that people can search a mysql database by each letter. Click on "A" get all records in the DB that start with "A". I have it working no problem but i want to be able to add "#" so that the user can get all records that start with a Number. For some reason the query i'm running won't grab any records that start with a number? here is the query:
Database Value Select In Combo Box!
This function is intended to display the current database field value as selected.. along with other values as general options. I can't figure out how to get it work. Help is appreciated!! function retrieve_category() { $cat = mysql_query("SELECT category_id FROM category"); while ($current_row = mysql_fetch_row($cat)) { $row = $current_row[0]; if ($row == $id) { printf("<option selected>%s</option> ",$current_row[0]); } else { printf("<option>%s</option> ",$current_row[0]); } } }
Populating A Select Box From A Database
I have a subscription database that allows you to edit a subscribers data. For example, you enter a search term like "Bob" and it returns a list of everyone named Bob. You click the one you want and it goes to a subscriber detail page, where all of his data is populated to a form. You can directly edit this form and click save to overwrite it. The only issue is the select boxes (drop downs) - say I have four options in the drop down box, red, blue, green and black. On my details page for bob I end up with five, I have those four PLUS whatever was saved for his color, so it shows up twice. If Bob is green, my select box looks like: Green Red Blue Green Black How can I make it so that Green only shows up once?
Select One Record From A Database
I am trying to select one record from a database. This databse has like 10 tables. I do not know which table this record is in. What php and mysql syntax would I use to accomplish this?
Randomly Select From Database?
this might seem like a stupid question, i should be able to do this. but on the front page of my site i want a thing to show a few users. but i dont want it to show the same people over and over. i want it to select different people each time. any ideas?
Selective Echoing And Database Select
I have written a search engine for business listings for the company I work for. Each listing is in a database, and that works fine. The problem though is two-fold. The first part of the problem is that not all listings utilise every column of the database, and this leaves gaps when echoing the results. This is not what i had in mind, Any ideas/help would be appreciated. The second part of the problem is related to the first in that there is a link for any listing that has a website, but not every listing has a website, so every listing having a "Visit our Site" link is impractical and shoddy. Also, i'm not sure how to echo the url from the database effectively in the first place.
Editing Mysql Database Row With Select Box
I have a small site, this small site has a few categories, now I can add items through my online admin area fine and delete them fine, but when it comes to editting them I am having some trouble, everything is working fine except the category column, because it is a drop down box I do not know how to have the category selected during the creation progress selected all the other info is loaded.
Multiple Select From Database Where Clause
I have a website with a database full of category names...I want to be able to chose lets say 5 of these categories and use a select from database clause where I could simply enter the category names I want to use but am not sure how I would go about doing it. I can get the list to display just the Aprilia category using the code below: $data1->q("SELECT * FROM categories WHERE cat_name = 'Aprilia' ORDER BY cat_name asc"); However...how could I get my site to display Aprilia, Ducati, Honda, Suzuki, Yamaha?
Using PHP And MYSQL To Select From Database Using Images
I'm trying to update a main page with a list of details matching a selection from a display of images that are displayed in a small window that have been selected from an image group using a select box in the main window, however I don't know how to do this and the main page is not receiving anything when clicking on an image so it's refreshing with empty data. I've seen many many pages giving examples of how to do this with select boxes or how to do this if only one entry uses an image shown in the small window, but the image display window is displaying many different small images not a select box and the database itself has multiple entries that use the same image. Can anyone help? I have a few instant chat programs if someone wishes to discuss this with me in real-time to see what it is I'm trying to achieve.
Tick Box, Select And Update Database.
I am trying to change the value in table with a tick box. If the tick box is selected it changes the value in the field to 'y' and if it is not selected it changes the field to 'n'. First of all I need to bring back the current state of the field and then I need to be able to update it from 'y' to 'n' as many times as I want. Code:
Population Select Menu Using Php And Database Values
I have no idea how to go about this. so i would apreciate some help i want to populate the values in a html select menu from database values in one table so i want all the values from 1 particular field in the database to be displayed in the select menu as separate options.
Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing <select name=categories> <? $cat_array = get_categories(); foreach($cat_array as $this_cat) { echo "<option value=""; echo $this_cat["category_id"]; echo """; echo ">"; echo $this_cat["category_name"]; echo " "; } ?> </select> ========================================================== function get_categories() { //get the list of categories from the database $conn = mysql_pconnect("localhost", "user", "pwd"); $query = "select * from categories"; $result = mysql_query($query); if(!$result) return false; $num_cats = mysql_num_rows($result); if($num_cats == 0) return false; $result = db_result_to_array($result); return $result; } //A function that returns a query to the database as an array function db_result_to_array($result) { $res_array = array(); for($count=0; $row=@mysql_fetch_array($result); $count++) $res_array[$count] = $row; return $res_array; }
Select Specific Phrase From MYSQL Database
I am working on a World of Warcraft guild's website and I am trying to create a page where players can select different kinds of gear, i.e. the gear with the most Stamina. All the player's items are stored in the database and every item have a field in the Items-table containing the item's tooltip. This could look something like: Boots of the Nexus Warden Soulbound Feet Cloth 97 Armor +27 Stamina +17 Intellect Durability 35 / 35 Equip: Improves spell hit rating by 18. Equip: Increases damage and healing done by magical spells and effects by up to 21. I then want to select the item with i.e. the most Stamina for all the different slots; Head, Chest, Legs etc. If I write this: $query = mysql_query("SELECT substring(item_tooltip, LOCATE('Stamina', item_tooltip)) AS maxor FROM roster_items WHERE member_id = ེ'") or die(mysql_error()); It returns the following: Stamina +17 Intellect Durability 35 / 35 Equip: Improves spell hit rating by 18. Equip: Increases damage and healing done by magical spells and effects by up to 21. But I want for it to show the leading characters also (in this case "+27 " before "Stamina") and then not show anything else after the phrase "Stamina". So it shows "+27 Stamina" and nothing else for the above mentioned item. How do I accomplish this? And then, secondly how do I then get it to show only the item with the most Stamina after it selected the above? Hope this makes any sense. I've tried to search these forums and found something a little along the lines of my problem but haven't been able to adjust them to my needs and I therefore need your help which will be greatly appreciated.
Reusing An Object For Common Select To Database
I've noticed that after I finished this app, I had repeated a similar task over and over and would like to modularize it. The repeated task was connecting to the database, executing a select, putting all the results of the columns into different variables of an object. PHP Code:
Error In Generating Table From Database Select Statment
I am trying to dynamically create a table with the results from a select statement. Below is the code that is not working. Any help would be oh so greatly appreciated. This is for a final at school which is due in an hour. This is the only thing I can't seem to make work. Code:
Select Specific Snippet Of Text, Replace With A Database Result
I'm having some problems trying to do something; I just can't think of a way to do it. Basically, I want to search for a specific snippet of text in a body of text, then replace it with the requested database result with some thrown in HTML. Users will be able to type the following (or something along these lines, depending on what works best): [image=12345]Insert caption here[/image] Then I need it to search for the requested image in the appropriate table and return the image's url (for an example, let's say the table is called "images", and the columns required are "imageid" and "imageurl". Code:
Simple Script For Doing A Simple Photo Album And Journal?
I'm looking to quickly get a photo album online. Very simple, thumbnails, a few pages, maybe a description, but hopefully a small script that's easy to edit and work into my existing site. I know about hot scripts, etc. but I was wondering if any one could recommend one? Secondly, I also want to setup a journal. It's not really a "blog" although I guess blog software may work. But it isn't going to be a message board or anything like that. Just a place to put out random bits of news. Once again, same premise, I'm trying to find the most simple script possible that could basically traverse a directory of simple textfiles and produce a list. I know all about Blosxom and stuff like that, but I'd like a script that just did the above and didn't overtake my site like PHPNuke or something like that. I'll probably roll my own, but I thought I'd check first.
Php Filter
I made a chat room with php and now im trying to make a bad word filter cna someone help me? not to code but to lead me in the right direction heres the script i have now thats not working Code:
Php Content Filter
I have made this script to filter content based on the given url. i need to make all the links on the page go through this script, so i added an str_replace and its not working, the links don't get modified.
Filter Arrays
there's an array where i want to remove one entry. so i use PHP Code:
Input Filter?
i have been searching for a good input filter class or how-to guide. All I found were vague concept descriptions or alpha-release or more than a year old, dead projects. Isn't there a comprehensive class to filter user inputs for specific purposes such as display, sql storage and filter features such as specific html tags, filter JS, etc etc?
Content Filter...
Would it be possible to make a PHP script that actted as a simple proxy server? I want to build a script that IE uses as a proxy, then i want to check the page for bad words and if its okay display it.
Drop Down Filter
I've got two drop down menus that I'm using to filter some data. It works when the user selects an option from both menus but always return ZERO records when only one of out the two menus have been set. My code POSTS the ID from each menu then puts that ID into the WHERE clause of an SQL query. Code:
Gzip Filter
I want to config gzip on apache server so that it compress everything except streaming files and images. I did AddOutputFilterByType DEFLATE text/plain text/javascript text/html. But it seems that certain request for file/image data gets gzipped as well. for example client sends a request http://myhost/file_streamer.php?id=101, my file_streamer.php respond with: Code:
Word Filter
I know there are many topics regarding Word Filters but I couldn't find one for this particular problem. I want to create a Word-Filter script which ignores workarounds such as spaces (B adword) or BB-codes (Badword). Any ideas on what specific code snippets to prevent those?
Strip_Tags Using Filter
I am trying to make code that will let users upload images and embeded object tags via a simple web form. I have it working correctly, it does what i want it to: user uploads say from a web form. it gets dumped into the sql table. this is the "behind the scenes" code that works on the form submission: Code:
Image Filter
The image size filter works but not the file extension filter. Would like a check to see if file exsists too. Code:
Spam Filter
anyone know a good spam filter for my linux email box...
Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution. So it goes <select name='status[]'>... <select name='resolution[]'> Then i have a another php page. $status = $_POST['status']; $resolution = $_POST['resolution']; Now my question is, how do i do the sql query statement? mysql_query("SELECT * from bugs where status=$status and resolution=$resolution"); The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.
How To Filter The Words In HTML ?
I face some problem that I want to filter the all words in HTML. Example: Before Filter: <div id="pp"hello man <br/Thank's for your answer. </div> After Filter: <div id="pp"<br/</div> What I want is reserve all HTML tags but words. Is there any good packages or classes or suggestion?
Creating Profanity Filter
I'm creating a profanity filter for my message board. I've created the following code: // $filter is the array that contains the bad words foreach ($filter as $word) { $name = eregi_replace($word,"*****",$name); $email = eregi_replace($word,"*****",$email); $subject = eregi_replace($word,"*****",$subject); $body = eregi_replace($word,"*****",$body); } The code works, but every word is being replaced by "*****" (5x*). That is not what I want. What I want to do is replace "doh" with "***" and "superdoh" with "********".
PHP Mail() And AOL Spam Filter
dodging AOL's spam filters when mail()ing from PHP? We are having trouble with this code: $fromEmail = 'aValidAddress@thisHostAccount.com' $headers = 'MIME-Version: 1.0' . " "; $headers .= 'Content-type: text/html; charset=iso-8859-1' . " "; $headers .= "From: This Foundation <$fromEmail> "; $headers .= "Reply-To: This Foundation <$fromEmail> "; $headers .= "Return-Path: $fromEmail "; $headers .= "Message-ID: <".time()." TheSystem@". $_SERVER['SERVER_NAME']."> "; $headers .= "X-Mailer: PHP v".phpversion()." "; mail($to, '$subject, $msg, $headers); We had originally been sending bounces to a different Return-Path address (see below) but simplified this after AOL flagged all the emails as spam. Also the To field is being set like this RealFirstName RealLastName <Addressand the message has a greeting using the RealFirstName. mail($to, '$subject, $msg, $headers, "-f bounce3@gnosports.com");
Bad Word And SHOUTING Filter...
Is there a simple way to go through a textarea input determine if certain words from a list (an array?) are present? And, related, sort of... Is there a simple way to determine if a textarea contains "too many" upper case characters ("shouting")? That is, count how many are UPPERCASE and how many not?
Adding A Filter To My Shoutbox
I have a simple shoutbox thingy that I use to display simple messages. It works fine as it is, but there is no error control or filtering etc.. I would really like to add a swear filter to it, but I'm not sure how. I tried using PHP Code:
Color Mask/Filter With GD?
Has anyone had any luck with trying to create a image mask with gd. I've gone through most of the manual and the closest thing I could get was http://www.php.net/manual/en/functi...phablending.php I want to put a color layer over and image that makes it look like it has a blue tint or red tint etc. The GD Manual isn't really any help either.
Displaying Images With A Filter
Wondering if someone can point me in the right direction. Im trying to display images from a directory, but i need to filter them. Like a wildcard, for example to display all images ending with *1h.png or to display images starting with cpu0*.*
Image Size And Ext Filter
I have been testing my image filters and have a few problems, for some reason it blocks .exe, .rar, .zip and a few others i have tested and does the if else code, but .psd .pdf (i have yet to test more)slip through the else code(they dont get uploaded but it creates a empty record. Not what i want. (why would it do that when in my array i only include, jpg, jpeg, gif and png files) The other problem is that it recongnises a jpeg if over the size limit and does the else code but png files bigger that the allowed size skip the else code and create an empty record(they dont get uploaded either) Code:
Image Upload Filter
I have this code i usethat works fine, except that any filr can be uploaded and any size. How would i add some code to check that the file is a jpeg, gif or png and is under 1 meg? Code:
Filter Links Out Of Comments
last week I posted a link to my site where people can leave comments and some low-life decided to post links on that page. Is there someway to filter out links? I dont really want to use the htmlspecialchars() or the htmlentities() to simply disable them, I want to block them altogether. Maybe some way to filter out "www" or something?
Filter To Omit Based On Certain Url
I have a script that will send an error for 404 emails. I want to exclude urls from a certain directory. How can I make it so they wont submit if /example is in the url? The code works fine I just want to filter out. Also you will see that I have defined REQUEST_URI this is because I have php on IIS, not my choice. I am somewhat of a noob, so if you can make your answer as simple as possible I would really appreciate it. Here is code:
How Do I Filter A Table Of Links ???
can anyone suggest a way of dissplaying a table of links from a mysql table but not display a link if a value is preasent in a colum of the mysql table ?
Filter Results Of Query
I am modifying some pages in CRE Loaded. allprods.php list all currently active products and I added a manufacturers column that displays who makes that product. I want to allow shoppers to filter the product list so that it shows only products from a particular manufacturer. I have gone through several scenarios in my mind, but nothing I've thought of seems simple and bullet proof. One of the issues is that the all products query includes all manufacturers. If I were to put a variable in the query to select only a particular manufacturer, how would I code it so it does not interfere with the all products query? Would logic based upon the value of a form action work? If form action exists, someone wants to filter. If not form action or form action = all, then they want the whole list. Seems like filtering a list is pretty common and there should be an easy solution.
|