Last active
April 17, 2016 09:07
-
-
Save MahbbRah/e4c5d4040fb0caa2ea8e398ce74227b4 to your computer and use it in GitHub Desktop.
Actually, I'm trying to to create a search form for a personal website that have single search form and multiple DB fields. if data match with input value then that field or similar all fields will echo .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_GET['submit_value']) && !empty($_GET['search_input'])) | |
{ | |
include("db_config.php"); | |
$db = database::getInstance(); | |
$searchValue = $_GET['search_input']; | |
$sql = "SELECT * FROM `sitedata` WHERE c_main_title LIKE '%$searchValue%' OR c_main_body LIKE '%$searchValue%' OR cmt_dept_title LIKE '%$searchValue%' OR cmt_dept_body LIKE '%$searchValue%' | |
OR aidt_dept_title LIKE '%$searchValue%' OR aidt_dept_body LIKE '%$searchValue%' OR food_dept_title LIKE '%$searchValue%' OR food_dept_body LIKE '%$searchValue%' OR rac_dept_title LIKE '%$searchValue%' | |
OR rac_dept_body LIKE '%$searchValue%' OR p_message_title LIKE '%$searchValue%' OR p_message_body LIKE '%$searchValue%' OR vp_message_title LIKE '%$searchValue%' OR vp_message_body LIKE '%$searchValue%' | |
OR about_college_title LIKE '%$searchValue%' OR about_college_body LIKE '%$searchValue%' | |
OR mission_message LIKE '%$searchValue%' OR vision_message LIKE '%$searchValue%' "; | |
// Now i want to match fields with my $searchValue var if fields match with input data then that fields will echo. otherwise won't. | |
$result = $db->dbc->query($sql); | |
foreach( $result as $row) | |
{ | |
// Now i need to use condition here to show my data which match with input field. | |
// like $field1 = " hello world this is me" and user input value = "hello world"; then this will show up! | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment