Web developers Get in here


#1

Hello Guys! Please I need your help. Am working on a project that works like A job search engine where when you enter Your Specialization and State and search you get redirected to another page displaying the available jobs of your specialization in that state . I want to do the same thing (Not for jobs) With PHP and a database…Someone show/tell me how. Thanks.


#2

I asume you already know how to connect php to mysql and how to use the basic sql statements.
What you need to do is save the information you want to search through in the databse and perform a SELECT for that table using direct string search e.g “Where username=‘Eddy’” or a broad search using LIKE e.g “Where author LIKE’%Chiamanda%’” . After selecting echo your results.
You can put your search form in one page and use the to redirect the result to another page or make use of Ajax and show the result on the same page


#3

Thank you @Eddy_Eddy but I kinda asked the wrong question… This is what I Actually want to do " I have created a form that has one text field and one select box, I also have created a button. Now what I want to happen is when the button is pressed I want the string in the forms to be matched up to my database and then I want the results of those matches to be returned and shown on the screen.

For example if I was to type ‘History’ into my text field box and I also selected ‘level 2’ from my select box when the button (Submit Button) was pressed I would want returned on the page everything that matches up with the word history and the selection of level 2 in my database.

I know that I have to connect my page with my Database through PHP and I have successfully done that, but what I don’t understand is how to then get my HTML Form to Query the database and provide results back onto the screen " I need a PHP code that can perform the operation…


#4

Have you added name attributes to your input fields ? . If you have, you can use this query `SELECT * FROM tablename WHERE column1 LIKE ‘%$name1%’ AND column2 LIKE '%$name2``


#5

I’d suggest you use stackoverflow.com as there are tons and tons of questions like this already answered there. If you can properly structure your google search query you should see something similar to what you are asking on stackoverflow.


#6

First and foremost, your search form is actually a form that performs a GET or POST request. I would allow you figure out if it should be a GET or POST request. In essence, the values of the form have to be sent to a PHP endpoint or page that would receive its input (the textbox and select dropdown) and use those parameters to query the database.

It is at this point that you would implement a query like what @Engrtitus suggested. You would then use a foreach statement to display the results and probably add a hyperlink so that they would be clickable.

My suggestions are a simplistic way of looking at it but they could give you a clue as to what you should do. If I were you, I would look into Algolia. But that is another kettle of fish.


#7

This is what you should do.
You have a form like this

Assuming you have a table called level_table and have 3 columns in it level_id, subject and level.
And a sample row is level_id =“5” subejct=“history” and level=“Level 2”

The form and php script below would help you do what you want to do. i used the basic php & mysql if you are using any framework you can simply implement the sql code through it.

<form action='' method='POST'>
<select name='level'>
<option>Level 1</option>
<option>Level 2</option>
</select>

<input type='text' name='search_keyword'>
</form>

 <?php
if(isset($_POST['search_keyword'])
{
$key_word = $_POST['seearch_keyword'];
$level = $_POST['level'];

$query = mysql_query("SELECT * FROM level_table WHERE level='$level' AND subject LIKE'%$key_word%' ");
foreach($query as $row)
{
$subject = $row['subject'];

echo"$subject </br>";
}
}
?>

#8

Thanks a lot guys for the reply… I really appreciate. Thank you.