how to load .php file to .html file – PHP



hey im new to php
look i got form with input and drop down menu in html files i want to load the content in the database in to the drop down menu
i want only in php file(to get the database) separte and html file(for form) separtly
im using in dreamweaver to do this help me…



If you want to populate your <select> box with data from your database, you can simply add PHP code to your form that fetches the data from the database, and prints each row as an option.

That generally goes something like:

<select name="items">
<option value="NULL">-- Select --</option>
// Fetch all items from a MySQL table
$sql = "SELECT `id`, `name` FROM `items`";
$result = mysql_query($sql);
// Print each item as an <option> box.
while($row = mysql_fetch_assoc($result)) {
echo "<option value=\"{$row['id']}\">{$row['name']}</option>";

You can also use JavaScript and AJAX to do this client-side. It’s not as simple, and not as reliable (people can turn of JavaScript), but it’s an option.


Atli thanks for your replay

hey look i will explain my problem i have database named as Comp which contains 3 tables 1st table with cat(containing the feild catid(primary key ,auto increment ) and catname)
2nd table with inst(containing the feild insid(primary key ,auto inc) and insname) 3rd table with traini(contining the feild trid(primary key with autoincremted) trname,insid,catid,trdate)

i can do form in .html for cat table which contains catname input field when click submit it insert data to my database(to insert table cat(for catname and autoincremented to catid) which is written in php.
and i can also do form in .html for inst table which contains insname input field when click submit it insert data to database(to insert table inst(for insname and autoincremented to insid) which is written in php.

<i cant do this help me>
But for form 3rd traini should show the feild for inserting(like trname) with the feild for 1st drop down menu for insname(which stored in database table of inst)
and 2nd drop down menu for catname(which stored in database table of cate)

and when we give submit it should insert into the database of traini(for trname, insid(from the database table of inst(feild of insid)),catid(from the database table of cate(feild of catid))


~Atli already explained how to build the dropdowns. What exactly do you need help with? Show us what you’ve done so far.


Kovik im beginner to php its my 3 day in it.i want just how to onload php file(which contains the fetching rows form the database) to html file which contain a drop downmenu and other form filling feild.i can able to fetch from database but i can’t load in html file containing the form feilds and dropdown.The form is in separate .html file and fetching is in separate .php file.Now when html file loads it should onload php file to it.Thats ALL
I want just how to preload a file PLEASE HELP ME


I don’t think you understand what PHP does. PHP is the "Hypertext Preprocessor." That means that its purpose is to generate HTML. HTML files don’t just "call" PHP, they are PHP.

Start using the *.php extension on all of your files that require dynamic content. Might as well use *.php for all of your files, period.


ok Thanks i did myself and i got it.