Jump to content
The Uniform Server Community


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

1 Follower

About vasu

  • Rank

Previous Fields

  • Main OS
    Windows XP
  1. vasu

    Insert query

    I have done it...... but then also it is not working.... I want it should enter the state_id from the state table.... I have done some modifications.... <? //ob_start(); session_start(); //include("../conn/config.php"); //include("../conn/dbclass.php"); $conn = mysql_connect('localhost','root','root') or die(mysql_error()); mysql_select_db('searchindia'); //$objDB=new dbclass(); $city_id = $_POST['city_id']; $state_id = $_POST['state_id']; $city_name = $_POST['city_name']; $statename = $_POST['state']; ///state is the dropdown box name/// $state = "SELECT state_id FROM state WHERE state_name = $state_id"; $state1 = mysql_query($state); $sql = " INSERT INTO city SET city_id='".$city_id."', state_id='".$state1."', city_name='".$city_name."'" ; //$objDB ->dbclass(); $a = mysql_query($sql) or die(mysql_error()); ?> <?php header('Location: indexlocation.php'); ?> <script> //window.location='index.php?p=location'; </script> <form action="indexlocation.php"></form>
  2. I have created two tables 1. state having fields state_id and state_name 2. city having fields city_id, state_id and city_name city id and state id is primary keys.... Now I want to insert city_id, state_id and city_name using three fields but i m not getting state_id i use ... $city_id = $_REQUEST['city_id']; $state_id = $_REQUEST['state_id']; $city_name = $_REQUEST['city_name']; $sql = " INSERT INTO city SET city_id='".$city_id."', state_id='".$state_id."', city_name='".$city_name."'" ; //$objDB ->dbclass(); $a = mysql_query($sql) or die(mysql_error()); mng_location.php indexlocation.php location.php
  • Create New...