![]() |
| ||
| php code to search and show results on same page I have a names database with only 4 fields (Sex, Origin, Meaning, Starts With) and html search form for those same 4 fields. Can anyone give me the php code so that if anyone fills in any or all of the form fields, the results from the database will be produced on the same page as the search form. |
| ||
| Re: php code to search and show results on same page Hi, you can have php code <?php echo $_SERVER['PHP_SELF'];?>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. :) |
| ||
| Re: php code to search and show results on same page 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 |
| ||
| Re: php code to search and show results on same page 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. |
| ||
| Re: php code to search and show results on same page <form action='<?php echo $_SERVER['PHP_Self']; ?>'> I like to add confirmation to the submit button, degrades ok with javascript disabled, |
| ||
| Re: php code to search and show results on same page Hi and thanks I will try this too and let you know how it goes regards |
| ||
| Re: php code to search and show results on same page Logial Correction, and statement of the obvious :icon_confused: <?php |
| ||
| Re: php code to search and show results on same page 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. |
| ||
| Re: php code to search and show results on same page 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' |
| ||
| Re: php code to search and show results on same page .. hey phpNewbie.. umm the sites i gave was a great help.. i am also a self taught coder.. i only search , read forums.. and it gave so much more than i think of.. it's easy to paste the code here but you have to learn it a step in a time.. goodluck, willing to give u code that can help :) |
| ||
| Re: php code to search and show results on same page more than you can ever read, compiled so you can find the part you need to read http://www.php.net/docs.php |
| ||
| Re: php code to search and show results on same page enim213 - thank you very much for the links you supplied - i really do appreciate your time to give them and will definitely make an effort to get the understanding - be afraid lol - if i come up with anything i'll be right back here for you to debug :) (or get your pasted code - kidding - or not lol) thank you almostbob for your link and code too at least today i got my basic html page made and my database loaded so that's a start :) |
| ||
| Re: php code to search and show results on same page Hi... i'm baaack Ok.. i made some effort (got myself more confused in the process - seem to be so many ways to do the same thing??) Anyway.. this is what i have now: Please help to add or change code to get this working. my sql statement works in phpmyadmin bringing back required results from the database but how do i get that happening on my webpage with the php and html. Apologies for my messy code but like i explained before, i'm absolutely new to php and finding it very difficult to get my 'blonde' head around it. Thanks again in advance for any help. <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| All times are GMT -4. The time now is 4:17 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC