I want to display only one account from the two relational table. For example if I inquire my account number and enter it, only the details of my account will be shown not every members. So in my output the whole members and its details inside the database display. How can I manage to display only one account from two relational tables? I know there is something wrong in my sql.
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT member.*, account.*
FROM member, account
WHERE member.mem_id = account.mem_id';
mysql_select_db('databasename');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "Account Number:{$row['Account_Number']} <br> ".
"First Name: {$row['fname']} <br> ".
"Last Name: {$row['lname']} <br> ".
"Address: {$row['address']} <br> ".
"Contact: {$row['contact']} <br> ".
"Share Capital: {$row['Share_Capital']} <br> ".
"Regular Savings: {$row['Regular_Savings']} <br> ".
"Power Savings: {$row['Power_Savings']} <br> ".
"--------------------------------<br>";
}
echo "Fetched data successfully\n";
mysql_close($conn);
?>
Now this is the output.
Account Number:
First Name:
Last Name:
Address:
Contact:
Share Capital:
Regular Savings:
Power Savings: