how to show matching record from the table based on the query on listbox

Discussion in 'PHP' started by kharearch, Jan 28, 2008.

  1. #1
    I have following fields on the form

    Bank, Personal loan, Home Loan, Education loan

    Listbox, text box, text box, text box


    On pressing bank list box I want to show matching record from loan table. How can I do this. All the fields are on the same form

    My code is following through which I am trying to do so. It is just populating the listbox. Please help me. I am a new user.

    But on selecting the option from listbox it is doing nothing.

    Code –

    <body>
    <?php
    $con = mysql_connect("localhost","sanganak_manish","manish");

    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);

    echo '<select>';
    $res = mysql_query("SELECT name, bplr,auto_loan from loan"); // add your query here
    if($res)
    {
    echo "hay" ;

    while($row = mysql_fetch_array($res))
    {
    echo "india";
    echo "\t\t<option value=\"" .$row[0] ."\"";
    if ($row[0] == $sel) echo "selected=\"selected\"";
    echo ">" .$row[0] ."</option>\n";

    }
    }
    echo '</select>';
    ?>
    <input type="text" name="textfield">
    <input type="text" name="textfield2">
    </body>
     
    kharearch, Jan 28, 2008 IP
  2. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you want to automatically change the value of the 3 text boxes every time the user selects a bank from the listbox, then you'll have to use javascript, or AJAX.
     
    CreativeClans, Jan 28, 2008 IP
  3. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Thanks for the reply.
     
    kharearch, Jan 28, 2008 IP