PHP - Help Or Point Me In The Right Direction, Search And Filter
OK guys so I have my final project for school due next quarter and Its a database management application. I'm dont the upload edit delete scripting but now I need to do the search feature on the front end. I have a basic understanding of the search abilities in PHP but what i'd love to do is create something like Istockphoto.com and many other inventory sites that allow for a "search" field and also a filter. I'd assume there needs to be global variables that will set and adjust the query as things are checked or filled out. does anyone know of any examples/tutorials/demos that I can browse to start figuring this out? Thanks
Similar TutorialsI'm just starting to research xml and I need to know if there's a specific name I should be looking for. I'm trying to read data from an xml file which is easy when all the tags are different but I've got a test file of students where alot of the data is the same. For instance: <STUDENTS> <STUDENT> <FIRSTNAME>Micheal</FIRSTNAME> <LASTNAME>Dorne</LASTNAME> <GRADE>10</GRADE> <MATHSCORE>89</MATHSCORE> <TEACHER>Flinn</TEACHER> </STUDENT> <STUDENT> <FIRSTNAME>Terry</FIRSTNAME> <LASTNAME>Williams</LASTNAME> <GRADE>11</GRADE> <MATHSCORE>78</MATHSCORE> <TEACHER>Edwards</TEACHER> </STUDENT> <STUDENT> <FIRSTNAME>Kimberly</FIRSTNAME> <LASTNAME>Jenson</LASTNAME> <GRADE>10</GRADE> <MATHSCORE>92</MATHSCORE> <TEACHER>Flinn</TEACHER> </STUDENT> </STUDENTS> I've reached a point where I need to acquire data from an xml file structured similar to this and need to know where to start. I could be looking for all the data on one specific student or acquiring a list of all student names that have the same teacher for example. I'd appreciate it if someone could point me the right direction with this. Thanks. Hi guys, I, not sure if this post belongs here as I have no idea what the cause of my problem is. However I'm hoping i can post the problems i have and one of you guys might be able to point me in the right direction as to where the problem is. Anyway up until a few days ago i had a system set up using php and mysql for customers to login to there accounts, buy and sell items etc. Every time a client would buy or sell an item a conformation email would automatically be generated and sent out with all the correct info already saved in the email. This system would also save the buy or sell information and a system administrator could login and view this info. The problem I have right now is that, none of this information is being saved any more, and the emails are not being generated. A client can do anything they want but no details are being saved. This problem just came out of nowhere, one day its was working fine, as it has been for well over a year now and then BANG! Its not working any more. Another strange thing is that I cant even seem to login into the administrator area on any other browser than firefox? I have really no idea why that is. I would also like to add that I have made no changes to the php code or the sql data prior to this problem. and lastly I think i should mention that this same system is on another completely different server, and the system has the exact same problem. If anybody has any clues to this one, or point me in the right direction I would be most grateful, as it has me completely stumped. Thank you very much in advance. H guys, I have created a quiz, however what i would like to do is have something that keeps an eye on the quiz. For example if someone is taking the quiz however get 4 incorrect answers in a row then it will abort the quiz. is it something like a for loop for example.... im not sure? The code i already got is a basic quiz however im just looking on expaning it more. Thanks for any help, i appreciate it! Code: [Select] <?php session_start(); $_SESSION['dclty'] = $_POST['dclty']; ?> <?php if ($_SESSION['dclty'] == "beg") ?> <script> window.open("extrahelp.php", height=300,width=300); </script> <?php if ($_SESSION['dclty'] == "int") ?> <script> window.open("pointers.php", height=300,width=300); </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Initial Quiz</h1><BR /> <form name="Forensics Test" method="post" action="detection.php"> <h1>Protection</h1> <hr /> <b>1. What does an IDS do? <BR /><BR /></b> <UL> <? if($attempted == true && !isset($q1)) { echo 'bgcolor="#FFFFCC"'; } ?> <input type="radio" name="q1" id="q1a" value="1" />An IDS evaluates a suspected intrusion once it has taken place and signals an alarm<BR><? if($q1 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q1" id="q1b" value="2">An IDS blocks intrusions before it happens and signal an alarm<BR><? if($q1 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q1" id="q1c" value="3">An IDS blocks all intrusions before it happens and monitors the network, however does not signal an alarm.<BR><? if($q1 == "1"){echo "checked=\"checked\"";} ?></UL><hr /> <b>2. What does a Firewall do?<BR /><BR></b> <UL> <? if($attempted == true && !isset($q2)) { echo 'bgcolor="#FFFFCC"'; } ?> <input type="radio" name="q2" id="q2a" value="1">Firewalls limit access once the intrusion is within a network and then signals an alarm.<BR><? if($q2 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q2" id="q2b" value="2">Firewalls limit access between networks to prevent intrusion and do not signal an attack.<BR><? if($q2 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q2" id="q2c" value="3">Firewalls limit access to a network and prevent all intrusions. An alarm to the user is raised.<br><? if($q2 == "1"){echo "checked=\"checked\"";} ?></UL><hr /> <p><b>3. What does Tripwire do?</b> </p> <UL> <? if($attempted == true && !isset($q3)) { echo 'bgcolor="#FFFFCC"'; } ?> <input type="radio" name="q3" id="q3a" value="1">Tripwire does not protect from intrusions however signals an alarm to the user that network intrusions are occurring.<BR><? if($q3 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q3" id="q3b" value="2">Tripwire does not perform system integrity checks in terms of file change, however does prevent access to a network unless otherwise stated.<BR><? if($q3 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q3" id="q3c" value="3">Tripwire helps identify changes in files. Tripwire records a set of information about all the important files in your server in case of a change.</p><? if($q3 == "1"){echo "checked=\"checked\"";} ?> <BR> </UL><hr /> <p><b>4. What type of files does a traditional anti-virus protect you from?</b> </p> <UL> <? if($attempted == true && !isset($q4)) { echo 'bgcolor="#FFFFCC"'; } ?> <input type="radio" name="q4" id="q4a" value="1">Viruses and tracking cookies<BR><? if($q4 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q4" id="q4b" value="2">Rootkits and Viruses<BR><? if($q4 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q4" id="q4c" value="3">Worms and Rootkits<BR><? if($q4 == "1"){echo "checked=\"checked\"";} ?> </UL><hr /> <p><b>5. What does an Anti-root kit protect you from?</b> </p> <UL> <? if($attempted == true && !isset($q5)) { echo 'bgcolor="#FFFFCC"'; } ?> <input type="radio" name="q5" id="q5a" value="1">Anti-rootkit protects from only viruses, key loggers and backdoors.<BR><? if($q5 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q5" id="q5b" value="2">Anti-rootkit protects from viruses, backdoors, spyware and key loggers as a collection.<BR><? if($q5 == "1"){echo "checked=\"checked\"";} ?> <input type="radio" name="q5" id="q5c" value="3">Anti-rootkit protects from only viruses and backdoors.<BR><? if($q5 == "1"){echo "checked=\"checked\"";} ?> </UL> <HR><BR /><BR /> <input type="submit" value="Go to Next Section" /> </form> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"> <p id="legal"> </p> </div> </div> </div> </body> </html> I've been at this for days, and the more I read the more confusing it gets. What I want to achieve is: I have a XHTML form with 5 user input fields - These a name subject cust_email telephone details I need to create a PHP script that will on user click - submit a email that has this format (secured if possible: From= cust_email Subject= "Customer requested information on" +subject eMail body= name + "requests information on" + subject /n + details /n + "Contact information" /n +telephone +email. So the body would look some how like this: Jane Smith requests information on Botox Hello I'm interested in botox injections please contact me with pricing and availability. Thank you. Contact information. (888)555-1212 Jsmith@hotmail.com Can you or anyone of the users in this wonderful forum HELP. I'm a print designer and I can assist you guys with anything you may need in print. But web is all to new and I'm struggling. Thank you, thank you very much. Not sure how to approach this ... I have a form where someone will select a city from a dropdown (over 80 cities currently, will be expanding to more). Each city falls in one of three categories (i.e. small, medium, large). After the user submits the form I need to determine what city the user selected and the size (small, medium, or large). Should I store the size in an array for each city name? That sounds wrong to me; or is it? I could use a switch statement I guess to check if 'New York' was selected and then set the city size to large, but that seems like excessive code also. Am I close? If you could point me in the right direction so I could read up on it, that would be awesome. Thanks! Code: [Select] <form action="meetme.aspx" method="post" id="form1" name="form1"> <input type="hidden" name="add_id" value ="28667977"> <input type="hidden" name="next26" value ="26883214,28590733,28654666,28681535,27273243,28576166,28613584,28591951,28515273,28541847,18296015,28594117,27206532,21878719,28590233,28663167,5039360,28636411,28569000,28645007,28587048,28569415,7815397,26626891,28671149,28570991"> <input type="hidden" name="p_Id" value ="28667977"> <INPUT TYPE="image" SRC="image/yes.png" NAME="votea" VALUE="1 <INPUT TYPE="image" SRC="image/maybe.png" NAME="voteb" VALUE="2'> <INPUT TYPE="image" SRC="image/no.png" NAME="votec" VALUE="3"> </form> I got this from datesite, But it suits my needs for something else. Exclude the 3 link options, I just want to use one. as a Next page button. and another as a back pagebutton. I made pagination already but I dont want that, I noticed pagination always keeps the same page, and just adds page numbers. But the same original page. The code above im assuming will allow to move to next new entire page with the new metas, and title and be botted by the search engines as a separate pages. And also keeping track of the next pages in que out of the entire specified db. So the question above is.. is there a page/website/tutorial.. terminology for this? pagination is pagination, is this like "form forwarding?? or something" ...So I can use.. Code: [Select] $sql = "SELECT COUNT(*) as Num FROM `mydb` Where models = ' 2012' and have it list all the values of say 'models' but keep them in memory passing to the next page and the next until they have all been viewed. Sorry if what im typing is overkill and you already knew what I asking in the first view of the code above lol. lemme know thanks! 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, I have a search page with a checkbox $departuk that returns the value "true" if checked. I want to return search results if this returns true and the flag 'Y' is available if ($departuk == "true"){ if ($data[$i]['departuk'] == 'Y'){ $result = $obj->result; } else{ echo "do some thing else"; } else{ echo"there was a problem"; } any pointers / advice is appreciated thanks Hey guys for a project im making a search filter function. Only one filter seems to be working and that's the genre filter :(
This is my code:
function filterFilms(){ global $conn; $loop = 0; if(isset($_POST['titel']) && !empty($_POST['titel'])){ $titel = sanatize($_POST['titel']); } if(isset($_POST['genre']) && !empty($_POST['genre'])){ $genre = sanatize($_POST['genre']); } $sql = "SELECT TOP 20 * From Movie Inner Join Movie_Director On Movie_Director.movie_id = Movie.movie_id Inner Join Movie_Genre On Movie_Genre.movie_id = Movie.movie_id Inner Join Person On Movie_Director.person_id = Person.person_id"; if(isset($titel) && !empty($titel)){ if($loop == 0){ $sql .= " WHERE ( title = ':titel' OR title like ':titel')"; $loop++; } else{ $sql .= " AND ( title = ':titel' OR title like ':titel')"; } } if(isset($genre) && !empty($genre)){ if($loop == 0){ $sql .= " WHERE genre_name = :genre"; $loop++; } else{ $sql .= " AND genre_name = :genre"; } } $query = $conn->prepare($sql); if(isset($titel) && !empty($titel)){ $query->bindValue('titel', $titel,PDO::PARAM_STR); } if(isset($genre) && !empty($genre)){ $query->bindParam('genre', $genre,PDO::PARAM_STR); } $query->execute(); $rows = $query->fetchAll(); return $rows; }
Anyone any idea??
hello. i have a search box that will display some results. I also have a drop down list with values "1" and "2". the values for each results are stored into database in a "req" field. Code: [Select] <select name="req" id="req"> <option value="1">yes</option> <option value="2">no</option> </select> $sql = 'SELECT * FROM topic WHERE (Title LIKE '."'%$search1%') AND req='1' what am i missing. thanks I'm ready for the next step on my site, which is learning how to filter results down with a second search. The scenario is: A viewer searches for a plant by 4 variables to describe the leaf. After submit, they go to the results page, with 200 paginated results. (This is where I've gotten to) Now, on that same page, they choose to further narrow their results by searching those 200 results for plants that have purple flowers. Maybe they get 40 results and can use another variable to narrow further - and so on. What's the best way to set this up? I've been looking into temporary tables, but it seems to be a challenge because the table deletes the moment they leave that page or close the connection? Sessions seem like another possibility, but I read there's security issues. What's the best way to set this up? Just re-query the database with the entire set of variables from both the first and second searches? is it quicker to build some type of permanent table with a timestamp that I can use to delete it after the user has gone away? This topic has been blindfolded and driven across the boarder to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=344623.0 (That was a pun, not a typo.) I have not coded much for a while, and when I did it was minimal. I played with PHP5 and MySQL a little, but that was a couple of years ago. The last website I built was in 2004 and it was tables upon tables in html. I am starting to learn all over again, can anyone recommend a good starting place or book for what might as well be a beginner. Thanks Bill I want to create a shopping cart system for my website, but a simple shopping cart. I don't want a registration form or anything like that, just a way to add or delete a product..... so, how am I going to achieve this? I don't know! I don't know what I am even suppose to be looking for. Though, I do suspect I need to learn something called "PHP sessions" to store a cookie on someones computer to keep the shopping cart active. I use MySQL for my database, so I am guessing I will need to also create some form of temporary storage table as well. To be honest, I am shitting myself and have feared this task for over a month, but I am brave and going to take the plunge. In my head I can picture the process actually being very simple: a cookie is stored on someones computer > adding to cart simply is a HTML form that PHP then adds to MySQL > on purchase PHP calls the data from MySQL and forwards it to the payment gateway API. ... but I am only asking for advice on the PHP session and storing the cart in MySQL... The payment API will be a simple matter of PHP pulling information from MySQL and forwarding it to the API. Can someone please point me to the right.... concept... or something? I am starting a project that will encompass the following- A forum script that will later be tied into it's own custom content management system. But I have some questions before I get too deep into starting: 1. What is the "most" secure way to code a forum system? 2. Shall I rely on 1 person to code or open it to the public to help too (open source)? 3. Which features of forum scripts do you like and why? 4. How should the plugin system (hooks) be designed? 5. Template system - what is the easiest way to make theming simple? These are just some of the basics that I am pondering at the moment. I know these may sound noobish but I would rather start this project the right way, instead of having it coded wrong etc.....and having to re-do everything down the road. So i've been wanting to expand my php horizons if you will and finally break of my fear of OOP. Here's a simple connection script i built, however i'm kind of stuck on a part of it. user passes username/password. i instantiate the mysqlcon class and call the connect function. the connect function attempts a connection to the database. if successful, pass on the username and password to the authenticator class. call the authenticate function. select user based on username/passwrod criteria. if found return "Confirmed" otherwise "Denied" here's my issue, i'm assuming that my Code: [Select] return $this->ok variable is returned back to the mysqlcon class. however how can i return that variable once more back outside of the object class so that i can continue with my script assuming authentication was confirmed. Here's my code... thanks for the help! <?php ## OOP PRACTICE ## class mysqlcon { function connect($user,$pass) { //Note: Connect to the database $db = mysql_connect("localhost", "usr","psw") or die(mysql_error()); if(mysql_select_db("database",$db) or die(mysql_error())) { $auth = new authenticator(); $auth->authenticate($user,$pass); } } } class authenticator { var $ok = "Confirmed"; var $ex = "Denied"; function authenticate($user,$pass) { //Note: User user and pass variables to check for user in table $qry = "SELECT * FROM users WHERE username = '$user' AND password = '$pass'"; $sql = mysql_query($qry) or die(mysql_error()); $cnt = mysql_num_rows($sql); if($cnt > 0) { return $this->ok; } else { return $this->ex; } } } $con = new mysqlcon(); $con->connect($_POST['username'],$_POST['password']); ?> PS: the classes are in class.php and the instantiation are in index.php. I just placed them together for easy of viewing. Alright I didn't really know what to name the thread but w/e. I'm working on writing a blog, just for the purpose of something to apply what I'm learning it's not for production. I need someone to point me in the general direction of how the front page would look where after a post is made its on top and the older posts are below it: -- new post -- old post -- old post I don't want the code just a general direction of how I should go about it. Thanks much. Hello, I defnitely don't consider myself a coder but have been installing and troubleshooting pre-made php scripts for a few years now and figure now is a good time to learn as I'm quite sick of having to rely on outsourced help I am currently trying to create a simple (hope so) script that will run on a cron every other minute to insert a specific piece of data each time a new member joins and it should only insert the data once based on criteria. Here's what I'm trying to do exactly with a php script check members table if field signup_date is TODAY's Date and if user_balance field is 0.00 then alter/update user_balance field 25.00 Now, I've hit a bit of a roadblock with getting the MySQL query format correct. The SIGNUP_DATE field in the database is DATETIME format and the like with wildcard thing isn't working for me. Is there anyone who can point me in the right direction with the proper wildcard date format? It'd be a great help. Anything at all is massively appreciated. Here's the code I have so far...the echo is in there so I can see if it's working correctly. I'm pretty sure I haven't got the right function to display the result of the query either but I think I can figure that out pretty easily. Code: [Select] <?php $today = date("Y-m-d"); mysql_connect("localhost", "DBUSER", "DBUSER") or die(mysql_error()); mysql_select_db("DBNAME") or die(mysql_error()); $sql1 = mysql_query("SELECT USER_NAME FROM members WHERE SIGNUP_DATE LIKE '$today%"); if($sql1 == false) { user_error("Query failed: " . mysql_error() . "<br />\n$query"); } elseif(mysql_num_rows($sql1) == 0) { echo "<p>Sorry, no rows were returned by your query.</p>\n"; } $memberseligible = mysql_fetch_array($sql1); echo "$memberseligible"; ?> I am creating a system for my students. I teach Photography and I want to do more online integration for my class. As of right now I have a whole system in which the students have their on accounts on my site. Now the challenging part for me. I need students to upload photos to me, and I will critique them. My questions for this forum a 1. Should I have a line of code that creates a folder per user to upload photos to? 2. Should I have the photos stored in the SQL database? 3. Are there any scripts out there that can be easily adapted for this idea? Adam Hello, I have been studying PHP for less than a year so please be gentle. I am building an agency website where users can add themselves etc. What I want to do now is allow clients to collect a list of these users which they can submit to the site along with a job description. What I actually need help with is sending the usernames to a 'collection' page. I want to allow the client to move between the profile pages selecting the users they like the look of and then be able to go to the 'cart/collection' page and see their list. I have a basic knowledge of sessions just no real idea how to pass variables/arrays. Any help would be much appreciated. Cheers - Lee. |