Hi all,

I want to add an amend functionality to my system. Therefore i need retrieve data from 2 different tables and display it in a single form.

account_details ( account_number, full_name,____)

account ( account_number, name_with_initials,____)

When i try to retrieve data from these 2 tables,output comes as an empty form.Can anyone correct my query.

$sql =sprintf("SELECT account_details. full_name,phone_number,address,gender,date_of_birth,account.name_with_initials,account_type,fd_period"." FROM account_details,account"." WHERE account_details.`account_number`='%s'", mysql_real_escape_string($_POST['account_number']) );

You need to JOIN query for both table.
Post your table structure.

The complete 2 tables are as follows

account_details (account_number,nic,full_name,phone_number,address,gender,date_of_birth,
approved_status)

account (account_number,name_with_initials,account_type,fd_period,account_balance,
account_interest)

Is your both table have one to one mapping OR one to many mapping?
Also you should have primary key in both table.

If one to one mapping then check below query in phpmyadmin.

select * from account LEFT JOIN account_details ON account.account_number = account_details.account_number

Still not working...data not retrieved. It results an empty form.

account_number is the primary key.It is one to on mapping table. One customer can have only one account.

I am not selecting all the records from both tables. So is it ok to use "*" in the query?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.