Hi! I am new to php and I want to know about country state city drop down populate from database.I searched it for everywhere most of them are used with javascript and some of them are don't work.please help me.
Can someone tell me about this in php
http://www.c-sharpcorner.com/uploadfile/satyapriyanayak/dfgd/
I'll appreciate it.
Thanks for your time!
Loading
Satyapriya NayakPosted Feb 17, 2013, 5:06 AM
Table Creation
-- phpMyAdmin SQL Dump
-- version 2.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 17, 2013 at 09:49 AM
-- Server version: 5.0.45
-- PHP Version: 5.2.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `Work`
--
-- --------------------------------------------------------
--
-- Table structure for table `city`
--
CREATE TABLE `city` (
`CityId` varchar(255) NOT NULL,
`State_Id` int(11) NOT NULL,
`CityName` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `city`
--
INSERT INTO `city` (`CityId`, `State_Id`, `CityName`) VALUES
('1', 1, 'Bhubaneswar'),
('2', 2, 'Hyderbad'),
('3', 3, 'Kolkata'),
('4', 4, 'Mumbai'),
('5', 5, 'Calgary'),
('6', 5, 'Edmonton'),
('7', 5, 'Duffield'),
('8', 6, 'Phoenix'),
('9', 7, 'San Diego'),
('10', 8, 'Austin'),
('11', 9, 'Toronto');
-- --------------------------------------------------------
--
-- Table structure for table `country`
--
CREATE TABLE `country` (
`Country_Id` varchar(255) NOT NULL,
`CountryName` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `country`
--
INSERT INTO `country` (`Country_Id`, `CountryName`) VALUES
('1', 'India'),
('2', 'Usa'),
('3', 'Canada');
-- --------------------------------------------------------
--
-- Table structure for table `state`
--
CREATE TABLE `state` (
`StateId` varchar(255) NOT NULL,
`Country_Id` int(11) NOT NULL,
`StateName` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `state`
--
INSERT INTO `state` (`StateId`, `Country_Id`, `StateName`) VALUES
('7', 2, 'California'),
('1', 1, 'Orissa'),
('2', 1, 'Andhra Pradesh'),
('3', 1, 'West Bengal'),
('4', 1, 'Maharastra'),
('5', 3, 'Alberta'),
('6', 2, 'Arizona'),
('8', 2, 'Texas'),
('9', 3, 'Ontario');
Now let's move to Coding part
config.php
$host="localhost";
$username="root";
$password="";
$dbname="Work";
$con=mysql_connect("$host","$username","$password");
mysql_select_db("$dbname",$con);
?>
Country State City.php
include('config.php');
?>
Thanks
If this post helps you mark it as answer
Sona KundnaniPosted Mar 23, 2013, 7:51 AM
wailin tunPosted Feb 23, 2013, 10:06 PM
what should I do?please help me again.
thanks for your time!