Friday, July 13, 2012

Creating MySQL table using php



Creating MySQL table using php 

Without going to MySQL interface you could create MySQL tables using php files.you have to paste the sql dump file content in the text area and submit


Create following php to get above result.

<?php
$create_table=$_POST['create_table'];
$con = mysql_connect("localhost","root","");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }



mysql_select_db("my_database", $con);

$sql = "$create_table";




mysql_query($sql,$con);



mysql_close($con);

?>
<form id="form1" name="form1" method="post" action="">
  <table bgcolor=#caae84 align="center">
<tr bgcolor=#ffffff><td><textarea rows="2" cols="20" name="create_table">
</textarea>
<tr bgcolor=#ffffff><td colspan=2><input type="submit" name="Submit"  value="Create Table" /></td></tr>
  </table>
</form>

No comments:

Post a Comment