PHP - Searching By Users' Personal Information
Similar TutorialsI just discovered that I have a major security flaw with my website. Anyone who logs in to the website can easily access other users information as well as delete and edit other users information just by changing the ID variable in the address bar. I have user ID Session started on these pages but still people can do anything they like with other users information just by editing the address bar. For example if your logged in in the address bar of www.mywebsite.com/delete_mystuff.php?id=5 and change the "5" say to a "9" then you will have access to user#9 information. Every important page that I have has this code: Code: [Select] session_start(); if (!isset($_SESSION['user_id'])) { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { //Else If Logged In Run The Script if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { $id = (int) $_GET['id']; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { $id = (int) $_POST['id']; } else { echo ' No valid ID found, passed in url or form element'; exit(); } What am I doing wrong? Please help if you know how to correct this. Many thanks in advance. Dear All respective friend, I'm asking for help. during I know how to code in php. I alway use md5() but I had some problem with abit. can anyone introduce me with persona code encryption without using md5()? Your ideal are very important to me especially small example code. Looking forward from you soon. Kindly Regards, Steve. hey guys im looking for some input from the comunity since this a complicated coding issue i will ask the pros!!! [PS that called sucking up ] Ok so here is my end goal! User arrive to a certain webpage He inputs his Web URL and hits submit. Here is where i get stuck as for my solution!. I would like to runs a script once the url is submitted that will scan the URL and collect and store information in a database, basicly i would like three things. i would like to save the sitename, url, description. I really hope this isnt as complicated as it seems. Thanks Hello
I am trying to work out how many regular users I have to my site and how long those users tend to be users..
So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id.
I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that...
SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; I really need some serious help with the design of a PIN (Personal Identification Number) Management System. When a user (with ID) logs in with the PIN (which already exist in my database), i want the system to assign that PIN to that user (ID) alone. No other user (ID) can access that PIN, the PIN is only assigned to that User (ID). I need the PHP codes, MySQL database tables, and some lil' explanation. Thanks. Hello, recently I changed host of my website and when a visitor clicks "contact us" button in my website (in which one needs to enter his/ her email, name, phone , etc) and submit his/her message then I get email. Before this hosting I used to get emails from the visitor who filled the form so it was easier for me to reply but now after I changed the host I get email as "mydomain@hosting-company-domain" instead of the visitor's email. I messaged them then they told me something about SMTP authenticate using PHP, please guide me to fix this. I'm having some trouble with a GET search code; everything works until the stringresult but then it dies to Error Querying Database Code: [Select] <html> <body> <?php //Get sort setting and search terms from URL with GET $usersearch = $_GET['usersearch']; echo 'Search word: ' . $usersearch; echo '<br>'; require_once("dbvars.php"); //Connect to Database $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PW, DB_NAME) or die ("Error connecting to database."); //Build the Query $query = "SELECT * FROM customers" . 'WHERE customers.given_name=\'' . $usersearch . '\''; echo $query; //Execute the Query $result = mysqli_query($dbc, $query) or die ("Error querying database."); //Create the Table Headings echo '<table border="1"><tr>'; echo '<td><b>First Name</b></td>'; echo '<td><b>Last Name</b></td>'; echo '<td><b>Address</b></td>'; echo '<td><b>City</b></td>'; echo '<td><b>Province</b></td>'; echo '<td><b>Postal Code</b></td>'; echo '<td><b>Phone Number</b></td>'; echo '</tr>'; //Display Results through Array Loop While ($row = mysqli_fetch_array($result)) { echo '<tr><td>' . $row['given_name'] . '</td>'; echo '<td>' . $row['surname'] . '</td>'; echo '<td>' . $row['address'] . '</td>'; echo '<td>' . $row['city'] . '</td>'; echo '<td>' . $row['province'] . '</td>'; echo '<td>' . $row['postal_code'] . '</td>'; echo '<td>' . $row['phone_number'] . '</td></tr>'; } '</table>'; // Close the database connection mysqli_close($dbc); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get"> <input name="usersearch" type="text" size="30" /> <input name="submit" type="submit" value="go" /> </form> </body> </html> Hi, I want to create a search which uses the 'title' of my 'product' table and matches the terms the user has submitted. At the moment, my products are displaying one by one. For example, I have an apple and apricot in my table. The user searches 'a' and the search results show 'apple' but not apricot. Here's my code: Code: [Select] <?php require_once('inc/global.inc.php'); # search.inc.php /* * This is the search content module. * This page is included by index.php. * This page expects to receive $_GET['terms']. */ // Redirect if this page was accessed directly: if (!defined('BASE_URL')) { // Need the BASE_URL, defined in the config file: require_once ('../includes/config.inc.php'); // Redirect to the index page: $url = BASE_URL . 'index.php?p=search'; // Pass along search terms? if (isset($_GET['terms'])) { $url .= '&terms=' . urlencode($_GET['terms']); } header ("Location: $url"); exit; } // End of defined() IF. // Print a caption: echo '<h2>Search Results</h2>'; // Display the search results if the form // has been submitted. if (isset($_GET['terms']) && ($_GET['terms'] != 'Search...') ) { $terms = $_GET['terms']; $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die *('Error connecting to MySQL server'); // Query the database. $query = "SELECT * FROM product WHERE title LIKE '%$terms%'"; $result = mysqli_query($dbc, $query); // Fetch the results. $row = mysqli_fetch_array($result); // Print the results: $output[] = '<ul>'; $output[] = '<li>'.$row['title'] .': £'.$row['price'].'<br /><img src="'.$row['img'].'" alt="'.$row['title'].'" /></li>'; $output[] = '</ul>'; echo join('',$output); } else { // Tell them to use the search form. echo '<p class="error">Please use the search form at the top of the window to search this site.</p>'; } ?> A friend told me I need to use a for-each loop but I can't figure it out. Any help is appreciated, thanks for reading. I've been reading a few tutorials on how the best way to search key words in a database and at the moment im trying to get this query to work but its coming back with a error:
#1191 - Can't find FULLTEXT index matching the column listquery: SELECT title, description FROM items WHERE MATCH(title, description) AGAINST('xbox')any help or advise on how the best way to search 2 columns on matching words...thank you So I've full text indexed the columns I want searchable: I have some rows inserted: Yet when I run a match() against(), I get 0 results: If I do: Code: [Select] SELECT * FROM video WHERE MATCH (name) AGAINST ('test') I get 2 results. Why does that work, yet keywords don't? Ok I have a set of PDF files that i need to be searchable. My question how do i go about doing this. Can this be achieved with php or do a need to do something else? Hi im really confused and annoyed Im making a real estate website and im stuck ont eh searching for a house part. Im trying to set up some searches on the different parts of the house usign text boxes for area and postcode and drop boxes for type and bedrooms and bathrooms i now you have to set up a form with input type text and then call it a name use get/post on a php side and then $_POST['search']; But i dnt seem to be able to make a search was hoping someone was kind enough to knock me up some quick code so it is functional and makbe i can work from it A;so any help towards searching using dropboxes would be awsume and if i have 2 boxes for price upper and lower how would this work Much appreciated Hello friends, i'm coding simple free script for articles but i need to know which url should be better 1- at this way article_title_words (sperated by _ ) 2- at this way article-title-words (sperated by - ) 3- at this way article+title+words (sperated by + ) which is better for searching engines ? thanks everybody Hi there, I'm working on PHP webform and I have a variable called $weightInfo which has the value 5000|6000 Now I have a list of Arrays and I would like to see if our variable value (i.e 5000|6000) is in that list of Array: Here is the ArrayList: $WeightArray = array('' => '', '0|100' => '100g or Less', '101|250' => '101g to 250g', '251|500' => '251g to 500g', '501|1000' => '501g to 1kg', '1000|2000' => '1kg to 2kg', '2000|3000' => '2kg to 3kg', '3000|4000' => '3kg to 4kg', '4000|5000' => '4kg to 5kg', '5000|6000' => '5kg to 6kg', '6000|7000' => '6kg to 7kg', '7000|8000' => '7kg to 8kg', '8000|9000' => '8kg to 9kg', '9000|10000' => '9kg to 10kg', 'customValues' => 'Custom Values' ); Now as we can see, in this ArrayList, there is that value 5000|6000. How do we find this through code, do we need some kind of looping or how do we check it. Kindly reply. Thank you I am including my test.php for other to run. I have a very large array of concatenated hash values. I have another array that contains the first 8 hash values of the other array. I have a function to locate them in the larger array. Depending on their index value I then choose the index of the value before or behind them for adding to something else later. This 'computeWalk' method works for small arrays but for larger arrays I notice duplicates or errors with larger ones. For example. The first array returns: Array ( => 1 [1] => 18 [2] => 18 [3] => 35 [4] => 33 [5] => 33 ) The values for i's to get each of these values are I = 0 I = 19 I = 29 I = 34 I = 37 I = 39 Walking through the method by hand, 0%2 = 0 So the first element of the array will be 1. CORRECT. 19%2 = 1 So the next element will be 18. CORRECT. 29%2 = 1 The next element should be 28. It returns 18. 34%2 = 0 The next element will be 35. Correct. 37%2 = 1 The next element should be 36. It returns 33. 39%2 = 1 The next element should be 38. It returns 33. I am not sure why it's doing the above. I also tried array_search and it computed it the same way. Would appreciate any help. <?php $arrayTree = array(); $arrayTree[0] = "9d027b1c4068d81287c9170f4b291387f8327eb7"; $arrayTree[1] = "4c8fabdc24c2d8205db916a22e9459195833a272"; $arrayTree[2] = "209526afab9e85b54e1832a820a7f578b7760af0"; $arrayTree[3] = "59d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[4] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9d"; $arrayTree[5] = "b207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayTree[6] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026"; $arrayTree[7] = "b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[8] = "d934f53af9bee26f35df7206dc06211778996986"; $arrayTree[9] = "de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayTree[10] = "7d9752d09d3097fac748b6767472f9b69a65ed2e"; $arrayTree[11] = "62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[12] = "d727b5b8ffaeadbac75123801c270fd65f19251c"; $arrayTree[13] = "e39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayTree[14] = "85fe053baa7ccf469c440a7dd98381228a0c52c3"; $arrayTree[15] = "6199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[16] = "af594de7d539519445013b7c87f02edbf3c44653"; $arrayTree[17] = "b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayTree[18] = "2163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[19] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272"; $arrayTree[20] = "209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[21] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayTree[22] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[23] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayTree[24] = "7d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[25] = "d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayTree[26] = "85fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[27] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayTree[28] = "2163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[29] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayTree[30] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[31] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayTree[32] = "d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[33] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[34] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232a"; $arrayTree[35] = "d934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[36] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[37] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayTree[38] = "af594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[39] = "9d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911deaf594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayTree[40] = "54u58rfhfheyrr4gfdtfvgw36tr36"; $arrayTree[41] = "54u58rfhfheyrr4gfdtfvgw36tr369d027b1c4068d81287c9170f4b291387f8327eb74c8fabdc24c2d8205db916a22e9459195833a272209526afab9e85b54e1832a820a7f578b7760af059d6926525e941edca99493b2b2a4f0a6efcb757c8b49b8e414a09ddb693c580ecdfa6793c845f9db207bea6c4833d90f6ee4e694ffb148c046b0eb36d72a84b3aefbd3766078ed17a19aebb0c4ae026b00207b8944520ea3817334615a7cdbf8214232ad934f53af9bee26f35df7206dc06211778996986de2ecd02fd017b0311dbfe589b5faa7954ced1967d9752d09d3097fac748b6767472f9b69a65ed2e62630fe109b42747b4c53065ec96aabf7b14d7b6d727b5b8ffaeadbac75123801c270fd65f19251ce39a9141fd9ce9426e88f30b6f245fdbb8f887a585fe053baa7ccf469c440a7dd98381228a0c52c36199634d410d0c91fd6ff99af9eabd5a1c7911deaf594de7d539519445013b7c87f02edbf3c44653b6eb6dab75d092f4be345925ccbf87ff1e17fc312163ca6b0a608242712af82a81599f1f95c26dee"; $arrayDocs = array(); $arrayDocs[0] = "9d027b1c4068d81287c9170f4b291387f8327eb7"; $arrayDocs[1] = "4c8fabdc24c2d8205db916a22e9459195833a272"; $arrayDocs[2] = "209526afab9e85b54e1832a820a7f578b7760af0"; $arrayDocs[3] = "59d6926525e941edca99493b2b2a4f0a6efcb757"; $arrayDocs[4] = "c8b49b8e414a09ddb693c580ecdfa6793c845f9d"; $arrayDocs[5] = "b207bea6c4833d90f6ee4e694ffb148c046b0eb3"; $arrayDocs[6] = "6d72a84b3aefbd3766078ed17a19aebb0c4ae026"; $arrayDocs[7] = "b00207b8944520ea3817334615a7cdbf8214232a"; $arrayDocs[8] = "d934f53af9bee26f35df7206dc06211778996986"; $arrayDocs[9] = "de2ecd02fd017b0311dbfe589b5faa7954ced196"; $arrayDocs[10] = "7d9752d09d3097fac748b6767472f9b69a65ed2e"; $arrayDocs[11] = "62630fe109b42747b4c53065ec96aabf7b14d7b6"; $arrayDocs[12] = "d727b5b8ffaeadbac75123801c270fd65f19251c"; $arrayDocs[13] = "e39a9141fd9ce9426e88f30b6f245fdbb8f887a5"; $arrayDocs[14] = "85fe053baa7ccf469c440a7dd98381228a0c52c3"; $arrayDocs[15] = "6199634d410d0c91fd6ff99af9eabd5a1c7911de"; $arrayDocs[16] = "af594de7d539519445013b7c87f02edbf3c44653"; $arrayDocs[17] = "b6eb6dab75d092f4be345925ccbf87ff1e17fc31"; $arrayDocs[18] = "2163ca6b0a608242712af82a81599f1f95c26dee"; foreach($arrayDocs as $doc) { $bitIndex = computeWalk($arrayTree, $doc); echo "<br/>"; print_r($bitIndex); echo "<br/>"; } function computeWalk($array, $needle) { $result = array(); for ($i = 0; $i < count($array) - 1; $i++) { if (false !== strpos($array[$i], $needle)) { echo " I = ".$i; if ($i % 2 == 0) { $result[] = getItemIndex($array[$i + 1], $array); } else { $result[] = getItemIndex($array[$i - 1], $array); } } } return $result; } function getItemIndex($item, $array) { $myPosition=-1; for ($i = 0; $i<count($array)-1; $i++) { if($array[$i]==$item) { $myPosition = $i; break; } } return $myPosition; } ?> Dear All, Greetings! I am a student and have a final semester project of making a php based form to search a database. Database is already created: Username: test password: test1 Details: DB Name: resume_bank, Table Name: Candidate Table contents: Name, Phone, Address, DOB, Gender, Designation, experience_yrs, experience_months, Employment_Status I need the code which would give the user an option to search using AND, OR, ALL functions. Friends please help. The form should look like: Enter the Designation you are looking for: Enter the experience: Yrs___ Months___ Select Gender: The result must come in another webpage which has numbered display results, like page-1, page-2, page3... PLEASE HELP URGENTLY!!!!!!! ANY BODY HAS READY MADE CODE PLEASE SEND IT!!!!!! Thanks. hey guys, im new to all this php stuff. I have a project in this semester to create an HR contract system for the university, here are my requirements: 1. Add Contracts 2. Delete Contracts 3. Edit Contracts 4. View Contracts 5. Search Contracts i have done all the 4 options but now im stuck in the 5th option. i have to use checkboxes filters for search and first and the last name fields. here is my form code <form method="post" action="searchCode.php"> First Name: <input name="name" type="text" id="name" /> Middle Name: <input name="mname" id="mname" type="text" /> Last Name: <input name="lname" id="lname" type="text" /> Date: <input type="text" name="date" id="currentdate" /> <input type="checkbox" name="gender[]" value="male" />Male<br /> <input type="checkbox" name="gender[]" value="female" />Female <input name="desig[]" type="checkbox" value="lecturar"/>Lecturar <input type="checkbox" name="desig[]" value="professor" />Professor <input type="checkbox" name="desig[]" value="assistantProfessor" />Assistant Professor <input type="checkbox" name="desig[]" value="associateProfessor" />Associate Professor <input type="checkbox" name="desig[]" value="researchAssociate" />Research Associate<br /> <input type="checkbox" name="desig[]" value="advisor" />Advisor <input type="checkbox" name="desig[]" value="HOD" </span> <input name="dept[]" type="checkbox" value="Comuter Science" />Computer Science <input type="checkbox" name="dept[]" value="Health Informatics Unit" />Health Informatics Unit <input name="dept[]" type="checkbox" value="Electrical Engineering" />Electrical Engineering <input type="checkbox" name="dept[]" value="Management Sciences" />Management Sciences<br /> <input type="checkbox" name="dept[]" value="Mathamatics" />Mathamatics <input type="checkbox" name="dept[]" value="Physics" />Physics <input type="checkbox" name="dept[]" value="Bio Sciences" />Bio Sciences <input type="checkbox" name="dept[]" value="Meteorology" />Meteorology <input type="checkbox" name="dept[]" value="Architecture" />Architecture <input name="scales[]" type="checkbox" value="sg1" />SG-I <input name="scales[]" type="checkbox" value="sg2" />SG-II <input name="scales[]" type="checkbox" value="sg3" />SG-III <input name="scales[]" type="checkbox" value="sg4" />SG-IV <input name="scales[]" type="checkbox" value="ras" />RA <input name="scales[]" type="checkbox" value="og1nphd" />OG-I- <input name="scales[]" type="checkbox" value="og2nphd" />OG-II-NonPhd <input name="scales[]" type="checkbox" value="og3nphd" />OG-III-NonPhd <input name="scales[]" type="checkbox" value="og4nphd" />OG-IV-NonPhd <input name="scales[]" type="checkbox" value="og2phd" />OG-II-Phd <input name="scales[]" type="checkbox" value="og3phd" />OG-III-Phd <input name="scales[]" type="checkbox" value="og4phd" />OG-IV-Phd</p> now i cant seem to get it in my mind tht how the hell im going to do tht...shud i use ifs and elses, in tht case it can get upto 256 combinations. and 1 more thing all these things are in one table....please gyus help me I am working on a poject, where the search functions doesnt work as the user wishes. The coding is technically correct, but the idea behind it is wrong. Basically at the moment, the script receives this: thesite.com/search.php?q=xxxx&Submit=Search The search script then runs a database query to search the tag coloumn, looking for like $q. This would work, however the structure of the coloumn is tag1, tag2, tag3, tag4. So my resolutions is this so far: I explode the $q variable, via the + (if you search more than one term "thesite.com/search.php?q=search+stuff&Submit=Search" I then count the elements in the array and write the database function accordingly Code: [Select] $var = @$_GET['q'] ; $trimmed = trim($var); $searchpieces = explode("+", $trimmed); $dbquery=""; $count = count($searchpieces); for ($i = 0; $i < $count; $i++) { if($i == 0){$dbquery.="tags = $searchpieces[$i]";} elseif($i > 0){$dbquery.=" OR tags = $searchpieces[$i]";} } So my database query is $sql = "select * from gallery where $dbquery order by date DESC " . $limit; so my question is this.. how to i eplode the tags database coloumn, so my datase query an look at each tag fro "tag1, tag2, tag3" as "tag1" "tag2" "tag3" I am not even sure if this is possible, but its the system that is already in place. The problem with the current system, is because the pictures have alot of tags and the database query is $like $q, it just shows all images in the database as the result I have a text string and I need to find the value that appears after a certain value: Value that appears after "XXX:" "Test 123 Hello XXX: 1 Test 555"; So the value would be "1" Any ideas? Hi, as a newbee i'm trying to figure this code out: $search = get_the_title(); $lines = file('links.txt'); // Store true when the text is found $found = false; foreach($lines as $line) { if(strpos($line, $search) !== false) { $found = true; echo $line,"<br/>"; } } // If the text was not found, show a message if(!$found) { echo 'not found'; links.txt file contains links like: <a href="https://blabla.com/blablabla/blablablabla/The word or file to search" target="_blank" rel="noopener noreferrer">The word or file to search</a> I just want to search the this part: ( ">The word or file to search</a> ) of the url then return it as an clickable url and also limit search results to 3. Could somebody help me which code and where to put in php code above? Thanks in advance. |