Jump to content

coolphpdude

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Everything posted by coolphpdude

  1. can it be done or could someone point me in the right direction of something that could help me?
  2. Any idea how then?
  3. what i actually want the user to do is go see the original results and then refine the results
  4. Hi, quick question for you... is it possible to search within a search result (refine an existing search). If i done an original search ($keyword as the searched word) e.g. $search = mysql_query("SELECT * FROM holidays WHERE holiday_hotel = $keyword") is it then possible on the next page to have another search box where the user could type in another keyword to search for? so for example, the user has searched for 'leazes hotel' and returned 30 results from various different countries around the world, could the user then search for 'france' as the location within that existing search result?? Thanks
  5. Not sure, i've been looking for it but can't seem to find it!
  6. your a star mate, works a treat! much appreciated!!!!
  7. Hi again, that hasn't worked for me. I'll copy my code in, the search variable is called $keyword $holiday_result = mysql_query("SELECT * FROM holidays WHERE holiday_id='$keyword' OR holiday_hotel LIKE %'.$keyword.'% OR holiday_area='$keyword' OR holiday_location='$keyword' OR holiday_description='$keyword' OR holiday_price='$keyword' OR holiday_status='$keyword'",$db); The part of the search where it checks the holiday_hotel is the only part i have altered so far. The reason i have only altered this part of the code is because it is only the hotel that i am querying for test purposes the final search facility will do a 'LIKE' search within all fields. Thanks again for your help
  8. Thanks i'll give that a try right now
  9. Hi, I need help on a project. Ive created a database where you upload details on a holiday (location, hotel, features of the hotel, price, etc...), so there are quite alot of fields. On the website i want to give the user a basic search facility. I want the user to be able to enter a single word or combination of words to search for matches within my database. So for example... if i have got this record in my database: Hotel: The Leazes Rooms: 2 Description: Beautiful modern hotel with swimming pool and kids club. If the user enters 'the leazes' it finds the hotel and displays the results, however, if the user searches for the word 'leazes' only then nothing is returned. Can any1 help with this? Thanks
  10. At the moment its adding the randomly generated code after the file extension
  11. hey guys, right, i need help picking apart the upload of a file. I'm at the point where i can upload the file to where i want it to go. what i want/need to make sure is that when the user uploads an image it is resized (i will do this later) and if the filename already exists then it is renamed. I currently have the following code: if ((($_FILES["uploadedfile"]["type"] == "image/gif") || ($_FILES["uploadedfile"]["type"] == "image/jpeg") || ($_FILES["uploadedfile"]["type"] == "image/pjpeg") || ($_FILES["uploadedfile"]["type"] == "image/png") || ($_FILES["uploadedfile"]["type"] == "image/bmp")) && ($_FILES["uploadedfile"]["size"] < 2000000)) { // Where the file is going to be placed $target_path = "uploads/$userid/$classid/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $_FILES['uploadedfile']['tmp_name']; echo "$target_path"; echo "<p>"; if (file_exists($target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name'])." exists"; echo "<p>"; // make the random file name $randname = md5(rand() * time()); echo "$randname"; $target_path = $target_path . $randname; echo "<p>"; echo "$target_path"; } else { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded"; } else { echo "There was an error uploading the file, please try again!"; } } } else { echo "invalid file type"; } ...This works ok to upload it to the location i want it to go but i problem is with pulling the filename apart to rename it if it already exists. Any help? Cheers
  12. champion, cheers lads
  13. cheers i'll give this a try
  14. Hey guys, this might sound like a daft question but here it goes; A user registers a username and password on a form which is then submitted and inserted into a 'user' table using the following code... $sql="INSERT INTO user (id, password) values ('$id', PASSWORD ('$password')"; now when a user comes to log in they enter the username and password they chose but because the password was encrypted when it was inserted into the database it doesnt match what they have entered to log in. What do i need to do??
  15. Thanks mate that works a treat!!
  16. i'll give that a try. Cheers
  17. Hi there, I am building a search query as i go by giving the user a number of different search options via a drop down box. I have removed all of the other search options that i am giving the user as they are irrelivent to what i am asking. The code I have so far is: FORM: echo "<select name='minmark'>"; echo "<option value='0'>No Preference</option>"; echo "<option value='20'>20</option>"; echo "<option value='25'>25</option>"; echo "<option value='30'>30</option>"; echo "<option value='35'>35</option>"; echo "<option value='40'>40</option>"; echo "<option value='45'>45</option>"; echo "<option value='50'>50</option>"; echo "<option value='60'>60</option>"; echo "<option value='70'>70</option>"; echo "<option value='80'>80</option>"; echo "<option value='90'>90</option>"; echo "<option value='100'>100</option>"; echo "<select name='maxmark'>"; echo "<option value='0'>No Preference</option>"; echo "<option value='20'>20</option>"; echo "<option value='25'>25</option>"; echo "<option value='30'>30</option>"; echo "<option value='35'>35</option>"; echo "<option value='40'>40</option>"; echo "<option value='45'>45</option>"; echo "<option value='50'>50</option>"; echo "<option value='60'>60</option>"; echo "<option value='70'>70</option>"; echo "<option value='80'>80</option>"; echo "<option value='90'>90</option>"; echo "<option value='100'>100</option>"; CODE: $querystring = "SELECT * FROM grades WHERE 1"; //test query if ($minmark != '0') { $querystring .= " AND mark>='$minmark'"; } if ($maxmark != '0') { $querystring .= " AND mark<='$maxmark'"; } echo "DEBUG: query = $querystring"; What i am trying to do is give the user the option of choosing to search for all records where a mark is within a minimum chosen mark and a maximum to chosen mark (the two drop down menu's from my form code), however, if the user chooses no preference it should search with no preference! My code is not returning correct results. Cany anyone tell me where i am going wrong??
  18. Sorted!! Thanks for your help you lot!
  19. right i kno y it dun it now because the i was returning a numerical value for grades (0=no preference, 1=A grade, 2=B Grade), problem is the drop down menu for the subject, 0=no preference but the value for the other options is corrosponding to the subject (0=no preference, maths=maths, english=english, etc...). i's there anyway i can use the same method but with text instead of only with numerical value's? thanks alot for your help.
  20. ive copied ur code, its working to an extent. it builds the first part (for the grade but it doesnt even do anything for the subject. any idea's?
  21. got a problem with what your suggesting. I understand now how to build a string which will form a query, theres 1 problem, we dont know how many criteria the user will choose to search from. if i give the user 6 search criteria and the user searches only 1 of these then there will be no need for the 'AND' command. however, if the user does choose more than 1 option then the 'AND' would be needed, how can i build this query?!?!
  22. hi thanks for your reply. I was using post for the passing of variables from the form to the code. im pretty new to strings so the code is a little hard for me to understand. the '.' does this add whatever is typed after it to the end of the string?? As far as i can see from that code it doesnt return all records for the options where the user selects no preference?
  23. is that due to the fact your pulling out all records n then deleting as you go which would make the query time longer?? Im even more stuck with option 1!! The way i was considering doing it was the following: if ($grade != '0') { $gradestring = "= '$grade'"; if ($subject != '0') { $subjectstring = "= '$subject"; $query = mysql_query("SELECT * FROM grades WHERE grade $gradestring AND subject $subjectstring"); $my_query_row = mysql_fetch_array($query); printf ("query result: %s", $my_query_row["grade"]); echo "<p>"; } else { $query = mysql_query("SELECT * FROM grades WHERE grade $gradestring"); $my_query_row = mysql_fetch_array($query); printf ("query result: %s", $my_query_row["grade"]); } } else if (subject != '0') { $subjectstring = "= '$subject'"; $query = mysql_query("SELECT * FROM grades WHERE subject $subjectstring"); $my_query_row = mysql_fetch_array($query); printf ("query result: %s", $my_query_row["grade"]); } else { echo "Please select at least one search criteria from our search options."; } my problem is that basically there is 2 possible outcome for every criteria that i give the user to search, these being 'yes something was chosen' or 'no the user had no preference'. If i give a user 6 search criteria thats 128 possibles outcomes and i would have to do 'if statements' to produce a query for EVERY possible outcome. Am i thinking of this right or is there a simpler way??
  24. Hi there, I am doing a (in my view) complex search query. its a school site where you can search a database to see what grades each student got in a selected subject. i have gave the user the options to select a grade from one drop down menu and select a subject from another drop down menu, the user can also select 'no preference' which will return a value of '0'. My problem is this... how do you program the script to return all records when value '0' is returned. The user might have no preference to what grade was acheived but want all the grades from maths, the user might want to see all students which received an 'A Grade' with 'no preference' to what subject, OR, the user might want to see all students that recieved 'A Grade' but only for 'maths' subject. Although i have only mentioned 2 possible search options above (grade and suject) I will be adding more criteria for the user to choose from to help them narrow results. This is where the search becomes complex to me. I have thought of two possible ways to do this: 1) build a search query as i go 2) do an overall search then delete records that do not match the criteria chosen by the user if i use option 1 then as far as im aware i will have to do 'if statements' for every eventuality. If i use option 2 im a little confused as to how to do it. Does any1 have any idea's how i can make this simple?? I personally am thinking option 2 might be best but i would need to take all records within the database into an array 1st and then delete out only the records that DO NOT match what the user selected (so if the user selected 'A Grade' the code would remove all records from the array where grade IS NOT EQUAL to A). I also have the problem with doing it this way how i would program the script to return all the results if the no preference value was returned. ANY help would be really appreciated.
  25. well im passed the problem about trying to insert text containing an '=' sign into a variable but i am still stuck! //test query if ($rooms != '0') { $roomsstring = "= '$rooms'"; } else { echo "no rooms selected"; } $query = mysql_query("SELECT * FROM tablename WHERE rooms $roomsstring"); I understand this bit but to make it also search a different field i have to come up with a way that automatically puts an 'AND' into the query to continue it on for the next field. Any ideas?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.