1. I can retrieve the data from MySQL and can view the results from the php file by opening it in a browser.
You appear to be on your way with this one . . .
I don't know how to bring the php file output to a html page, so that I can view my MySQL data from a html page and I want to add more html codes to get better view of the results.
You don't put PHP in an HTML page. By default, PHP will only execute files with a PHP extension, however, you **can** configure your server to parse .htm(l) extensions as php. It's just not a great idea, PHP should stay php, htm(l) should stay HTML.
However, nearly all of what PHP does is
output HTML to a browser.
You can use the echo or print command, or drop "in and out of PHP" - I prefer the former.
(Assuming you have executed mysql_fetch_array() or similar and stored results in $row...) $some_content = "<p>" . $row['title'] . "</p>";
echo $some_content; // or print $some_content;
or
<p><?php echo $row['title']; ?></p>
2. I want to add a search form in the html page, so that I can search the MySQL database and view the results back in html page.
Looks like you're on your way with the forms. What you do is parse and
cleanse input values from $_GET or $_POST which is determined by your form action. Then you use the submitted velues in a query. Like
// This is one example of cleansing - remove anything but letters, numbers, spaces, basic punctuation
// Not the greatest, but cleansing is condition-specific
$search = preg_replace('/[^a-z\d\'\"\s\.\,]+/i','',$_POST['search']);
$query = "select * from some_table where yourfield='. mysql_real_escape_string($search) . "'";
Learn it now, before bad habits start to form (and they will, they always do, for all of us:) the most important thing you can learn about programming is not what you can do with it, it's how to properly cleanse input.
3. I have a column named "tag" in my database and each row has several words on the tag column. ... I want to have a link for each tag in my html page that can bring me the results of the corresponding tags.
When you say "several words," what do you mean? Like, comma separated?
id|tag
1|this,that,the other thing
This is the beginning of a poor database design, and I'll tell you why. If you were to search on these terms, it becomes very unwieldy, very fast. You are limited to the LIKE operator or a regexp to search on these fields, both of which are fairly slow. You will likely be forced to do in programming what you can do with straight mysql select statements, which will make your programming unnecessarily complex.
The better solution is to use multiple tables and joins in what is callded database normalization. Consider . . .
products table
id|product
123|Widget
tags table
id|product_id|the_tag
12|123|green
13|123|blue
14|123|green
Here we have a product called Widget with three tags, red, blue, and green. Instead of like or regexp, we can use the equality operator and a join:
$query = "select products.product,tags.the_tag from products, tags where products.id=tags.product_id";
This will return three rows:
Widget|red
Widget|blue
Widget|green
It will be faster and more efficient.
(A more common solution is to use inner, outer, right, or left join operators but the equality in the where works just as well.) Look into database normalization and mysql joins. Many programmers cobble something together that works, but in doing so they begin to develop bad habits that don't scale and often have to be scrapped later. Investigate input cleansing and efficient usage of database queries while you're still learning it, you'll be glad you did.