How To Create Table In MySql Using PHP
In this tutorial i will let you know How To Create Table In MySql Using PHP.This tutorial will be very helpful when you are thinking of create a database table through your PHP code.
CODE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>How To Create Table In MySql Using PHP</title> <style type="text/css"> body { margin:0px auto; width:980px; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; } h2 { font-size:30px; text-align:center; } .text { color:#090; text-align:center; font-size:20px; } .hr { clear:both; margin-top:60px; border-bottom:solid 2px rgba(0,0,0,0.4); } .footer { width: 100%; text-align: center; padding-top: 0px; font-size: 16px; } </style> </head> <body> <h2>How To Create Table In MySql Using PHP</h2> <div class="text"> <?php $connection= mysqli_connect("localhost","joon","joon"); if($connection){ echo "Connection Established"; } else { echo "coonection fail"; } //Select Database mysqli_select_db($connection,"demo"); //Create Table $create= "CREATE TABLE Employee ( Eid int(10)AUTO_INCREMENT PRIMARY KEY, Employee_Firstname varchar(100), Employee_Lastname varchar(100) )"; if (mysqli_query($connection,$create)) { echo "<br><br><br>Table Employee created successfully"; } else { echo "<br><br><br>Error creating database: " . mysqli_error($connection); } ?> </div> <!--hr--> <br /><br /><br /><br /> <hr /> <!--footer--> <div class="footer"> <p>© 2013 All rights reserved by HighTechnology.in <a href="http://hightechnology.in" target="_blank">HighTechnology.in</a> | Hosting Partner <a href="http://www.grootstech.com" target="_blank">Grootstech Solutions</a></p> </div> </body> </html>