First connect to Mysql Database
// define variables
$dbhost = 'localhost';
$dbuser = 'root';
$dbpassword = 'jagdeep';
$con=mysql_connect($dbhost,$dbuser,$dbpassword) or die ("cannot connected") ;
$dbname = "ppl";
$tablename = "map";
?
save this file as "common.inc" used for others files.
Create Database and table.
<?php // define variables
$dbhost = 'localhost';
$dbuser = 'root';
$dbpassword = 'jagdeep';
$con=mysql_connect($dbhost,$dbuser,$dbpassword) or die ("cannot connected") ;
$dbname = "ppl";
$tablename = "map";
?
save this file as "common.inc" used for others files.
Create Database and table.
include "common.inc";
$create_db = "CREATE DATABASE $dbname ;"; //Create Query for Create database
mysql_query($create_db) or die ("can't create database"); //Create Database
mysql_select_db($dbname)or die("cant connect"); // Select database
$create_table = "CREATE TABLE $tablename ( latitude DOUBLE NOT NULL, longitude DOUBLE NOT NULL,title VARCHAR (50),description VARCHAR(50), icon VARCHAR (20),icon_size FLOAT(10) , icon_offset VARCHAR (20) , date DATE NOT NULL ,time TIME NOT NULL ,PRIMARY KEY (latitude));"; //Create Query for Create Table
mysql_query($create_table)or die(" can not create table" );//Create Table
?>
Create html page for insert the data in database.
<html>
<title>
ADD NEW RECORD
</title>
<link href="jsm.css" rel="stylesheet" type="text/css">
<form action="newrecord.php" method ="post">
<table>
<H2> ADD NEW RECORD </H2>
<tr>
<td>Latitude: </td>
<td><input type ="text" name="latitude"></td>
</tr>
<tr>
<td>Longitude:</td>
<td ><input type ="text" name="longitude"></td>
</tr>
<tr>
<td> Title:</td>
<td><input type ="text" name="title"></td>
</tr>
<tr>
<td> Description:</td>
<td ><input type ="text" name="description"></td>
</tr>
<tr>
<td> Icon:</td>
<td ><input type ="text" name="icon"></td>
</tr>
<tr>
<td >Icon Size:</td>
<td ><input type ="text" name="icon_size"></td>
</tr>
<tr>
<td> Icon Offset:</td>
<td ><input type ="text" name="icon_offset"></td>
</tr>
<TR>
<TD>Date:</TD>
<TD>
<!-- You can use PHP functions to automatically get the value of date -->
<INPUT TYPE='TEXT' NAME='date' VALUE='<? echo date("Y-m-j"); ?>'>
</TD>
</TR>
<TR>
<TD>Time:</TD>
<TD>
<!-- You can use PHP functions to automatically get the value of time -->
<INPUT TYPE='TEXT' NAME='time' VALUE='<? echo date("g:i a"); ?>'>
</TD>
</TR>
<tr>
<td align ="center">
<table >
<tr>
<td >
<td ><input type ="Submit" name="submit" value ="Add"></td>
<td><input type ="reset" name="reset" value ="Reset"></td>
</tr>
</table>
</tr>
</table>
</from>
</body>
</html>
No comments:
Post a Comment