retrieve value from mysq DB & display in textboxe based on value inputed to other tex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sapproject
    New Member
    • Mar 2014
    • 2

    retrieve value from mysq DB & display in textboxe based on value inputed to other tex

    i want to display house rent from the database depending on the house number.I have written the following code.This code neither gives an error nor displays the corresponding house rent from the DB


    <td><label >26. House No.***(C179)</label></td> <td><input type="text" name="houseno" size="5" maxlength="5" tabindex=25 onblur="checkNa me2(this.value) " value="<?php if ($done==false && isset($_POST['submit'])) echo $_POST['houseno'];?>"></td> </tr> <tr> <td>27. House Rent</td> <td><input type="text" name="house_ren t" size="4" tabindex=26 maxlength="4" onBlur="checkNu mber2(this.valu e)" ></td> <?php
    if(isset($_POST['houseno']))
    {
    $houseno =$_POST['houseno'];
    $sql2 = mysql_query("se lect * from house_rent where HOUSE_TYPE='$ho useno' ") or die(mysql_error ());
    $result = mysql_query($sq l2);

    while ($row = mysql_fetch_arr ay($result)) {
    echo "<option value='" . $row['RENT'] ."'>" . $row['RENT'] ."</option>";
    }
    echo "</select>";
    }
    ?> </tr> <tr>
  • sapproject
    New Member
    • Mar 2014
    • 2

    #2
    Code:
    <td><label >26. House No.***(C179)</label></td> <td><input type="text" name="houseno" size="5" maxlength="5" tabindex=25 onblur="checkName2(this.value)" value="<?php if ($done==false && isset($_POST['submit'])) echo $_POST['houseno'];?>"></td> </tr> <tr> <td>
    
    
    
     <td>27. House Rent</td>
        <td><input type="text" name="house_rent" size="4"  tabindex=26 maxlength="4" onBlur="checkNumber2(this.value)" ></td>
     <?php
    if(isset($_POST['houseno']))
    {
     $houseno =$_POST['houseno'];
    	$sql2 = mysql_query("select * from house_rent where HOUSE_TYPE='$houseno' ") or die(mysql_error());
    	$result = mysql_query($sql2);
    	
    	while ($row = mysql_fetch_array($result)) {
        echo "<option value='" . $row['RENT'] ."'>" . $row['RENT'] ."</option>";
    	}
    	echo "</select>";
    }
    	?>
    This is the code

    Comment

    Working...