Top
Home

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Create Database
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

<?php
$con=mysqli_connect("127.0.0.1","admin","admin");
if (mysqli_connect_errno())
 {
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }
$sql="CREATE DATABASE FreakZoidx";
if (mysqli_query($con,$sql))
 {
 echo "Database created successfully";
 }
else
 {
 echo "Error creating database: " . mysqli_error($con);
 }
?>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Create Table
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

<?php
$con=mysqli_connect("127.0.0.1","admin","admin","FreakZoidx");
if (mysqli_connect_errno())
 {
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }
$sql="
CREATE TABLE `Farmer` (
`id` int(11) NOT NULL auto_increment,
`FirstName` varchar(250) NULL DEFAULT NULL,
`LastName` varchar(250) NULL DEFAULT NULL,
`ip` varchar(250) NULL DEFAULT NULL,
`todae` varchar(250) NULL DEFAULT NULL,
PRIMARY KEY  (`id`)
)
";
if (mysqli_query($con,$sql))
 {
 echo "Table created successfully";
 }
else
 {
 echo "Error creating table: " . mysqli_error($con);
 }
?>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Add Field
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

<?php
$con=mysqli_connect("127.0.0.1","admin","admin","FreakZoidx");
if (mysqli_connect_errno())
 {
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }
$sql="
ALTER TABLE Farmer ADD Email VARCHAR(60) FIRST;";
if (mysqli_query($con,$sql))
 {
 echo "New Field created successfully";
 }
else
 {
 echo "Error creating Field: " . mysqli_error($con);
 }
?>