Php/Mysql Export data from two tables

I need to export data from two tables Php/Mysql to Excel or CSV file. I try with Union All but I get data in one cell I need next format:

Name:   Age (from another table)
Levan   22
Dito    35
Giorgi  46

I receive next:

    header("Content-type: text/csv; charset=UTF-8");
    header('Content-Disposition: attachment; filename=Export.csv');

    $con = mysql_connect('localhost', 'user', 'pass');
    if(!$con) {
        echo "Error connection";

    //select db
    $select_db = mysql_select_db('database', $con);
    if(!$select_db) {
        echo "Error to select database";

    mysql_set_charset("utf8", $con);

    //Mysql query to get records from datanbase
    $user_query = mysql_query('SELECT Amount FROM Credit UNION ALL SELECT username FROM User');

    //While loop to fetch the records
    $contents = "Amount \t username\n";
    while($row = mysql_fetch_array($user_query)) {      

    $contents_final = chr(255).chr(254).mb_convert_encoding($contents, "UTF-16LE","UTF-8");
    print $contents_final;


SELECT Credit.Amount, User.username FROM Credit INNER JOIN Users ON Credit.username = Users.username

The problem was the user columns were different in each table

credit->UserID User: username

try this:

SELECT Credit.Amount, User.username FROM Credit INNER JOIN Users ON Credit.UserID = Users.username

Need Your Help

rendering Unicode glyphs

java unicode rendering

I want to render Unicode glyphs to jpg format. Should I change the font for each Unicode block in my java Code? I tried not to do that, but it did not work. However, changing the font for each block

AVAudioEngine Input Mic Tap influences Music PlayerNode - SWIFT

ios format microphone avaudiosession avaudioengine

I am creating an app that lets the user talk into the microphone while music is playing (similar to Karaoke). I have managed to get this working using the AudioEngine with multiple inputs going int...