First of all this is a crazy thing I have just done.. so please sit back and read the whole post.............. Today I finished my math final and decided to learn a new programming language..... MYSQL. So I was able make my way to http://www.freewebmasterhelp.com/tutorials/phpmysql using Google I followed most of the tutorial and got the database setup... up until part 4; Everything works great and now I am just curious that how can I make a small page called search.php in which I can make a small search box. and have only one result display from the MySQL?
Jump to Post
Create a html form like this:
<form action="search.php" method="post"> <input type="text" name="search"><br> <input type="submit"> </form>
<?php $search = "%" . $_POST["search"] . "%"; mysql_connect ("localhost", "myuser", "mypassword"); mysql_select_db ("mydatabase"); $query = "SELECT mycolumn FROM mytable WHERE mycolumn LIKE '$search'"; $result = mysql_query ($query); …
All 5 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.