search+display from database
Hey everyone,
I am new to PHP and doing my assigment so I need a little help.
I need to display some informations from SQL database.
Basically, I know the html part, and i made it.
I'll have two inputs, search field, and drop down , and Im using method post, and I need to write independent PHP scripts.
I supose I need two variables, one for drop down and one for search field.
I wonder how to write that correctly in PHP, and how to;
- get results from DB for that two fields
- display them back in my html file
If someone can advise me on this, I'd be grateful.
Thank you in advance!
So, I have DB with countries and area codes, and I need to make search. I wrote html;
<form method="post" action="search.php">
Country:
<select name="country">
<option value="algeria">Algeria</option>
<option value="afganistan">Afganistan</option>
<option value="austria">Austria</option>
</select>
Area Code: <input type="text" name="area">
<input type="submit" name="search" value="Search">
</form>
I know the part with connecting to database, but I dont know the method to display right informations for dropdown + search..
Can anyone help?
Thanks in advance..
Use the $_POST array to access the form inputs. (See http://www.php.net/manual/en/languag...s.external.php .)
Then read up on whichever database extension you plan to use for the specific RDBMS you'll be using.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
Thanks..
I made $country = "$country" and then queryied db for column that is %like% $country, echoed results in the end..
And now Im stuck with the client need to remember drop down selection..
I wonder if it can be done with php?
See the $_SESSION super-global array along with the session_start() function for retaining values across pages by the same user.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks