I have two tables in my mysql database: female and male. They both have 3 columns each: id, name and age. I want a html table to be displayed with both table's data in it.
I have these code pieces:
$result = mysql_query("SELECT * FROM female ORDER BY age DESC LIMIT 20");
while($row = mysql_fetch_array($result))
{
$age = $row['age'];
$name = $row['name'];
}
and
$result01 = mysql_query("SELECT * FROM male ORDER BY age DESC LIMIT 20");
while($row01 = mysql_fetch_array($result01))
{
$age01 = $row01['age'];
$name01 = $row01['name'];
}
So how should I mix these tables (the data)? Should I use the mysql UNION
function or something else? What is the appropriate code for this job?
Thanks...