| | |
php code to search and show results on same page
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jun 2008
Posts: 40
Reputation:
Solved Threads: 2
Hi, you can have php code on your form action to return the results in the same page.
and in the top of your page(the same page with the form), add conditional statements for all/any or search form fields and then query them ..
Show us your code for us to debug it.
php Syntax (Toggle Plain Text)
<?php echo $_SERVER['PHP_SELF'];?>
and in the top of your page(the same page with the form), add conditional statements for all/any or search form fields and then query them ..
Show us your code for us to debug it.
•
•
Join Date: Jan 2009
Posts: 13
Reputation:
Solved Threads: 0
hi and thanks for your reply. I have no code (embarrassed) and was hoping someone could give me example with only 4 fields to query. I have no idea about php. I know how to make html form and i have .sql file to import to database but that is all. I dont know how to write the php code to make it all happen. I am making searches for scripts to play with but they are very confusing for me. I would very much appreciate any help you can give.
kind regards
kind regards
•
•
Join Date: Jun 2008
Posts: 40
Reputation:
Solved Threads: 2
with that... try to search tutorials on google.. try website like w3schools.com, tizag.com.. there are many examples there.. including php and mysql for your data fetching.. when your done, post it quick here for us to know..
Actually its simple.. but we want something even a little effort.. that would really help you.
Actually its simple.. but we want something even a little effort.. that would really help you.
php Syntax (Toggle Plain Text)
<form action='<?php echo $_SERVER['PHP_Self']; ?>'> <input type='text' name='field1' value='<?php if(isset($field1)){echo $field1; } ?>'> <input type='text' name='field2' value='<?php if(isset($field2)){echo $field2; } ?>'> <input type='text' name='field3' value='<?php if(isset($field3)){echo $field3; } ?>'> <input type='text' name='field4' value='<?php if(isset($field4)){echo $field4; } ?>'> <input type='submit' onclick="return confirm('Are all fields complete?')">
I like to add confirmation to the submit button, degrades ok with javascript disabled,
Last edited by peter_budo; Jan 9th, 2009 at 6:13 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
Logial Correction, and statement of the obvious
php Syntax (Toggle Plain Text)
<?php /* logical construct depends on your data,,, validate data entries, if valid insert to mysql, disable submit so data will not be aded to table twice, or redirect to another page else echo feedback to user to explain what is right/wrong with the submitted data before the form is resubmitted */ ?> <form action='<?php iecho $_SERVER['PHP_Self']; ?>'> <input type='text' name='field1' value='<?php if(isset($field1)){echo $field1; } ?>'> <input type='text' name='field2' value='<?php if(isset($field2)){echo $field2; } ?>'> <input type='text' name='field3' value='<?php if(isset($field3)){echo $field3; } ?>'> <input type='text' name='field4' value='<?php if(isset($field4)){echo $field4; } ?>'> <input type='submit' onclick="return confirm('Are all fields complete?')">
Last edited by almostbob; Jan 8th, 2009 at 11:50 pm.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Jun 2005
Posts: 60
Reputation:
Solved Threads: 5
Well now my go.
I have done something very very similar.
No you cannot have the code. It is MUCH MORE FUN it you work it out for your self.
For a start something that the previous posters forgot, what happens if more than one matching row is found (i.e. only the 'Sex' field was filled in?
The previous examples show HTML forms being used. I would suggest that you look at text boxes and handle the input / display using javascript and good old (new?) AJAX. Remember fields do not have to exist when the page is first displayed on the client screen. the DOM allows you to create objects, and set their values and all other properties on the fly.
QUICK TIP use different text areas for user input and data display, when the user submits some data expect it to be partial data and leave the focus in the same fiedl that the user last used. If the user submits "Pat" and you list out all of the Pat's / Patricia's & Partick's that you can find, the user will find it much easier to go on to finish Patraig.
I would recommend you get 'THE JAVASCRIPT BIBLE'. It contains a huge amount of information and will guide you through your first steps in implementing this type of function.
I have done something very very similar.
No you cannot have the code. It is MUCH MORE FUN it you work it out for your self.
For a start something that the previous posters forgot, what happens if more than one matching row is found (i.e. only the 'Sex' field was filled in?
The previous examples show HTML forms being used. I would suggest that you look at text boxes and handle the input / display using javascript and good old (new?) AJAX. Remember fields do not have to exist when the page is first displayed on the client screen. the DOM allows you to create objects, and set their values and all other properties on the fly.
QUICK TIP use different text areas for user input and data display, when the user submits some data expect it to be partial data and leave the focus in the same fiedl that the user last used. If the user submits "Pat" and you list out all of the Pat's / Patricia's & Partick's that you can find, the user will find it much easier to go on to finish Patraig.
I would recommend you get 'THE JAVASCRIPT BIBLE'. It contains a huge amount of information and will guide you through your first steps in implementing this type of function.
•
•
Join Date: Jan 2009
Posts: 13
Reputation:
Solved Threads: 0
Hi thanks for your reply but you may as well have written it in arabic for all my understanding lol.
Allow me to explain - i'm absolutely new to php - had never even seen it before now beginning to research - i'm completely self taught html and some database and so what you have said makes no sense to me whatsoever. me being blonde doesn't help either lol so i wanna keep it very simple. I'm sure it would be a lot of fun to work it out myself but i work full time (not in IT) and have three kids so thats gonna take quite a while. I think my best bet is to just work through tutorial after tutorial, however long it takes - unless you wanna sell me your code lol - kidding
Thank you all for trying to help but i fear its just way over my head for now and maybe i should find another less confusing project to take up my 'spare' time (like naughts and crosses lol) - unfortunately i just don't 'get it'
Allow me to explain - i'm absolutely new to php - had never even seen it before now beginning to research - i'm completely self taught html and some database and so what you have said makes no sense to me whatsoever. me being blonde doesn't help either lol so i wanna keep it very simple. I'm sure it would be a lot of fun to work it out myself but i work full time (not in IT) and have three kids so thats gonna take quite a while. I think my best bet is to just work through tutorial after tutorial, however long it takes - unless you wanna sell me your code lol - kidding
Thank you all for trying to help but i fear its just way over my head for now and maybe i should find another less confusing project to take up my 'spare' time (like naughts and crosses lol) - unfortunately i just don't 'get it'
![]() |
Similar Threads
- How to limit page numbers for search results for database website (PHP)
- PLS I NEED YOUR HELP! Help on Reading and Editing of already Written CODE on php! (PHP)
- Using PHP/HTML to update informationin MySQL (PHP)
- delete and refresh search results (JavaScript / DHTML / AJAX)
- Problem with page navigation (PHP)
- Problem with PHP Search Code.... (PHP)
- multiple search terms+fulltext search (MySQL)
- php results from form - stuck (PHP)
- search and results question. (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP Friends request system!
- Next Thread: Validation of form
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube






