usman07 Posted March 7, 2012 Share Posted March 7, 2012 How would i begin to start php coding to work for this form shown in the image? could anyone point me to useful tutorials, i would appreciate it, thanx Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/ Share on other sites More sharing options...
litebearer Posted March 7, 2012 Share Posted March 7, 2012 Have you tried anything yet? At what level would you say your php & myslq skills are? Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324819 Share on other sites More sharing options...
usman07 Posted March 7, 2012 Author Share Posted March 7, 2012 I have done a login using php and mysql, but I need something to work with, like a tutorial or something? how difficult is it to do a search form with the image i shown? Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324821 Share on other sites More sharing options...
usman07 Posted March 7, 2012 Author Share Posted March 7, 2012 Would you say this website is useful for what i want to do? http://php.about.com/od/phpwithmysql/ss/php_search_5.htm Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324822 Share on other sites More sharing options...
trq Posted March 7, 2012 Share Posted March 7, 2012 how difficult is it to a search form with the image i shown? From the looks of your questions I would say very. If you have done a login system then you have already worked with forms and databases (hell, you've even had to search the database for a specific user already). Why not try and apply that same knowledge to a different problem? Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324823 Share on other sites More sharing options...
usman07 Posted March 7, 2012 Author Share Posted March 7, 2012 I could use that same knowledge, but doing a search form will be different because it needs to display results? and i dont have a clue on how to go about doing that. im surprised there is not any real tutorials online. Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324824 Share on other sites More sharing options...
trq Posted March 7, 2012 Share Posted March 7, 2012 im surprised there is not any real tutorials online. There would be literally thousands of tutorials around that show you how to display data from a database. ANyway, why not make a start by simply posting a search term to a php script and have the php script send that term to the database? See if you can get some results in an array. Once you have that, see if you can loop through that array and display it's data on a web page. Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324825 Share on other sites More sharing options...
usman07 Posted March 7, 2012 Author Share Posted March 7, 2012 ahhh right ok, Thank You il do that. Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324826 Share on other sites More sharing options...
usman07 Posted March 7, 2012 Author Share Posted March 7, 2012 Am i on the right lines with the php code for a search form? basically i want data from the mysql database to output and show on the website depending on what the users search is. (im new to php) <?php $username=""; $password=""; $database=""; mysql_connect("","",""); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM tablename"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $field1-name=mysql_result($result,$i,"id"); $field2-name=mysql_result($result,$i,"Location"); $field3-name=mysql_result($result,$i,"Property type"); $field4-name=mysql_result($result,$i,"Number of bedrooms"); $field5-name=mysql_result($result,$i,"Purchase type"); $field6-name=mysql_result($result,$i,"Price range"); echo "<b>$field1-name $field2-name2</b><br>$field3-name<br>$field4-name<br>$field5-name<hr><br>"; $i++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324889 Share on other sites More sharing options...
trq Posted March 7, 2012 Share Posted March 7, 2012 You need to pass the data a user submits through the form into a WEHRE clause in your query. Other than that, yeah, that is one way to display results from a database query. It's not the cleanest of most common way however. Take a look at mysql_fetch_assoc and the examples of it's usage. Quote Link to comment https://forums.phpfreaks.com/topic/258458-how-write-php-for-a-search-form/#findComment-1324979 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.