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.
phpNewbie
0
Newbie Poster
Recommended Answers
Jump to PostHi, 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 …
Jump to Postwith 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 …
Jump to Post<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 …
Jump to PostLogial Correction, and statement of the obvious :icon_confused:
<?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 …
All 15 Replies
enim213
1
Light Poster
phpNewbie
0
Newbie Poster
enim213
1
Light Poster
almostbob
866
Retired: passive income ROCKS
phpNewbie
0
Newbie Poster
almostbob
866
Retired: passive income ROCKS
pclfw
23
Junior Poster
phpNewbie
0
Newbie Poster
enim213
1
Light Poster
almostbob
866
Retired: passive income ROCKS
phpNewbie
0
Newbie Poster
phpNewbie
0
Newbie Poster
wacmo
0
Newbie Poster
aprillyn.ruado
0
Newbie Poster
tqmd1
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.