By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,148 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

second select of dynamic box

P: 1
hello friends i hava a code like this and could any body help me with editing code and send me code. i am getting city values but i can't location values of city from database.thanks in advance. <html>
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <title>demo</title>
  3. <body>
  4. <form method="POST" action="http://localhost/vtigercrm/modules/Webforms/
  5. post.php">
  6.  <input type="hidden" value="Leads" name="moduleName" />
  7.  <table>
  8.   <tbody>
  9.    <tr>
  10.       <td><label>Last Name</label></td>
  11.       <td><input type="text" name="lastname" value="" /></td>
  12.    </tr>
  13.    <tr>
  14.       <td><label>First Name</label></td>
  15.       <td><input type="text" name="firstname" value="" /></td>
  16.    </tr>
  17.    <tr>
  18.       <td><label>Company</label></td>
  19.       <td><input type="text" name="company" value="" /></td>
  20.    </tr>
  21.    <tr>
  22.       <td><label>email</label></td>
  23.       <td><input type="text" name="email" value="" /></td>
  24.    </tr>
  25.    <tr><td><label>city</label></td><td colspan=1>
  26.        <select name="city">
  27.         <option>city</option>
  28. <?php
  29. $connect=mysql_connect("localhost","root","venkataz");
  30. if(!$connect) die("access failed");
  31. $select=mysql_select_db("vtigercrm530");
  32. if(!$select) die("select failed");
  33. echo "selected vtigercrm530";
  34. $query="SELECT DISTINCT address_city FROM vtiger_users";
  35. $result=mysql_query($query);
  36. if(!$result) die("database access failed:" . mysql_error());
  37. while($row = mysql_fetch_array($result))
  38. {
  39.   echo "<option value>".$row['address_city']."</option>";
  40. }
  41. ?>
  42. </select>
  43. </tr>
  44. <tr><td><label>lane</label></td><td colspan=1>
  45. <select id="lane" onselect="show();">
  46. <option>location</option>
  47. <script type="text/javascript">
  48. function show()
  49. {
  50. var lane=document.getElementById["lane"].selectedIndex;
  51. alert(lane);
  52. }
  53. </script>
  54. <?php
  55. $connect1=mysql_connect("localhost","root","venkataz");
  56. if(!$connect1) die("access failed");
  57. $select1=mysql_select_db("vtigercrm530");
  58. if(!$select1) die("select failed");
  59. echo "";
  60. echo "<br/>";
  61. $query1="SELECT address_city FROM vtiger_users";
  62. $result1=mysql_query($query1);
  63. if(!$result1) die("database access failed:" . mysql_error());
  64. $lcity=$_REQUEST["city"];
  65. $rows=mysql_num_rows($result1);
  66. for($j=0;$j<$rows;$j++)
  67. if(mysql_result($result1,$j,"address_city")==$lcity)
  68. {
  69.  $query2="SELECT address_street FROM vtiger_users WHERE address_city='".mysql_result($result1,$j,'address_city')."'";
  70. $result2=mysql_query($query2);
  71. while($row= mysql_fetch_array($result2))
  72.  {
  73. echo "<option value>".$row['address_street']."</option>";
  74.  }
  75. }
  76. ?>
  77. </select>
  78. </td></tr>
  79.   </tbody>
  80.  <table>
  81.  <input type="submit" value="Submit" />
  82. </form>
  83. </body>
  84. </head>
  85. </html>
Apr 20 '12 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 2.5K+
P: 2,545
What's your question? You have not told us so far.
Apr 21 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.