3 Tables, 1 answer...
MAIL Table has a the fields mail_name, dom_id and account_id
ACCOUNTS Table has the id and password
DOMAINS Table has id and name
What I want is to give it an email address which would be
mail.mail_name@domains.name and get the password (mail.account_id goes into accounts.id)
ALL Help is appreciated
Help retrieving data from multiple tables in a database
Moderator: General Moderators
If you have a column in each table that's equal to the information in eachother table's columns... (If, in each row, in the mail table you had row_id equal to two, in the accounts table you had row_id equal to two, and in the domains table you had row_id equal to two) you could try....
I might be way off
Good luck!
Code: Select all
<?php
$query = "SELECT * FROM mail, accounts, domains WHERE mail.row_id = accounts.row_id AND accounts.row_id = domains.row_id ORDER BY mail_name ASC";
$result = mysql_query($query) or die("<P>Query failed: ".mysql_error());
while($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "E-Mail: ".$line['mail_name']." <br> Password: ".$line['password'];
}
?>Almost maybe?
So here is what i got
but I am getting an error
Parse error: parse error, unexpected T_VARIABLE in /home/httpd/vhosts/blaht.com/httpdocs/email.bak/part2.php on the $query line
Help please
Code: Select all
<?php
$link = mysql_connect($host, $user, $password)
$query = "SELECT * FROM mail, accounts, domains WHERE mail.mail_name = '$username' AND mail.dom_id = domains.id AND mail.account_id = accounts.id ORDER BY mail.mailname ASC";
$result = mysql_db_query($dbname, $query, $link) or die("<P>Query failed: ".mysql_error());
while($line = mysql_fetch_array($result))
{
echo "<br><br>The Email Address : ". $line['mail.mail_name'] . $line['domains.name'] . " <br> The Password: .$line['password'];
}
?>but I am getting an error
Parse error: parse error, unexpected T_VARIABLE in /home/httpd/vhosts/blaht.com/httpdocs/email.bak/part2.php on the $query line
Help please
Code: Select all
<?php
$link = mysql_connect($host, $user, $password);
$query = "SELECT * FROM mail, accounts, domains WHERE mail.mail_name = '".$username."' AND mail.dom_id = domains.id AND mail.account_id = accounts.id ORDER BY mail.mail_name ASC";
$result = mysql_db_query($dbname, $query, $link) or die("<P>Query failed: ".mysql_error());
while($line = mysql_fetch_array($result))
{
echo "<br><br>The Email Address : ".$line['mail_name'].$line['name']." <br> The Password: ".$line['password'];
}
?>