Fetch data from database I want to fetch student result from database, by asking user to enter roll number and name. I have created a webform to take inputs but I don't know how to fetch the records from the database and display it in tabular form. Kindly tell how to fetch the record and display it.

One thing I tried is create a form in basic page content type using HTML and do the required using PHP, but I cannot figure out how to do if the form is created using Webforms.
The requirement you have asked can be easily achieved without making custom queries or use of webform module

Consider this:
If the students enrolled are supposed to login into your site, then with no doubt use user entity and wherever you want to list the students in tabular form or simple list use views module as suggested before.

If the students are not supposed to login to the system they go well with node entities,for that simply create a content type as students with field on it as you require like roll number etc.. again to list them simply use views module it will do the query for your plus will allow you to show the results in tabular way.