1

I am new to PHP.

I'd relly appreciate it if someone could please point me in the right direction for a tutorial on how to populate multiple text fields based on a dynamic drop-down list selection (entries from a MySQL table). I'm new to PHP and MySQL and I'm busy trying to build a page that when I select an item from a drop-down list, that has been populated from a MySQL table, it populates multiple text fields with the appropriate information from that table

For example, if I select "client name" from the selection box then the text fields Email, Phone and Address get populated with "Client name", email, phone, address from the same table. columns are = id, name, email, phone, address, key person, additional info

MY PHP CODE FOR SELECTBOX:

    <?php
    include('../db_connection.php');
    $sql="SELECT name,id FROM add_client order by name"; 
    echo "<select name=name value=''>Client Name</option>"; // list box select command
    foreach ($con->query($sql) as $row){//Array or records stored in $row
    echo "<option value=$row[id]>$row[name]</option>"; 
    }
    echo "</select>";// Closing of list box
    ?>

Screenshot# 01

table- column (for Reference)

Screenshot# 02

My Table name is: add_client Db Connection file: db_connection.php

Hasnnnaiin
  • 73
  • 7

1 Answers1

0

Use ajax (php, mysql, jquery) on click event of fetch button, and populate data in input fields.

click here

Ajit Maurya
  • 56
  • 1
  • 9