将aukciono_id从一个表转移到另一个表

I am trying to transfer "aukciono_id" from one table to another. I was trying to do it using a single while loop and maybe it would work but the main problem is when the user hovers over the element class "placiau", another table displays not hovered element's "aukciono_id". I just cannot use while loop because while loop iterate through the query one by one. I have to identify every <td class="placiau"></td> "aukciono_id" somehow. Also, the table should appear next to the hovered element but I will fix it by myself.


<table>
<?php
$aukciono_laimetojai_ir_aukciono_istorija_while = mysql_query("SELECT taw.id AS taw_id,
    tai.aukciono_id AS tai_aukciono_id, taw.user_id AS taw_user_id, taw.win AS taw_win,
    tai.date AS tai_date, taw.date AS taw_date, COALESCE(SUM(tai.bid), 0) AS tai_bid
FROM tb_auction_winners taw JOIN tb_aukciono_istorija tai
ON taw.id = tai.aukciono_id
WHERE tai.user_id = 206 GROUP BY aukciono_id");

$aukciono_istorija1_while = mysql_query("SELECT tab.id, tu.level, tab.user_id, tab.user,
    tab.bid, tab.date, tab.aukciono_id FROM tb_aukciono_istorija tab JOIN tb_users tu
ON tab.user_id = tu.id
WHERE tab.aukciono_id = 47 ORDER BY tab.id DESC");

while ($r1 = mysql_fetch_assoc($aukciono_laimetojai_ir_aukciono_istorija_while)) {
    if ($r1['taw_user_id'] == 206) { ?>
        <tr>
            <td><?php echo $r1['taw_date']; ?></td>
            <td><?php echo $r1['taw_win'] - $r1['tai_bid']; ?> Eur</td>
            <td>0 Eur</td>
            <td class="placiau">Plačiau <?php echo $r1['tai_aukciono_id']; ?></td>
        </tr>
<?php
    } else { ?>
            <tr>
                <td><?php echo $r1['tai_date']; ?></td>
                <td>0 Eur</td>
                <td><?php echo $r1['tai_bid']; ?> Eur</td>
                <td class="placiau">Plačiau <?php echo $r1['tai_aukciono_id']; ?></td>
            </tr>
<?php
    }
}
?>
</table>
<table id="aukciono_apzvalga" style="
width: 69.7%;
left: 632px;
position: absolute;
top: 590px;
z-index: 1;
opacity: 0;
-webkit-transition: opacity .5s ease-out;
transition: opacity .5s ease-out;
display: block;
overflow-y: auto;
max-height: 480px;">
<?php
    while ($r1 = mysql_fetch_assoc($aukciono_istorija1_while)) { ?>
        <tr>
            <td><?php echo $r1['aukciono_id']; ?></td>
        </tr>
<?php } ?>
</table>

<script>
    $('.placiau').hover(function() {
        $('#aukciono_apzvalga').css('opacity', 1);
    }, function() {
        $('#aukciono_apzvalga').css('opacity', 0);
    });
</script>

Picture how it looks like:

enter image description hereNote: 47 is just a random number as an example how it looks like

When the user hovers "42", for example, it should show 42, instead of 47 in the other table and also in the "$aukciono_istorija1_while" query. Is it possible to do so?

PS: I know, I should use mysqli_* or PDO instead of mysql_*

Problem solved! :) It was a bug in the while loop.

</table>
<?php
while ($r1 = mysql_fetch_assoc($aukciono_istorija1_while)) { ?>
<table class="aukciono_apzvalga" data-aukciono-id="<?php echo $r1['aukciono_id']; ?>" style="
width: 69.7%;
left: 632px;
position: absolute;
top: 590px;
z-index: 1;
opacity: 0;
display: block;
overflow-y: auto;
max-height: 480px;">
    <tr>
        <th colspan="5">Aukciono apžvalga</th>
    </tr>
    <tr>
        <th>Nr.</th>
        <th>Žaidėjas</th>
        <th>Lygis</th>
        <th>Suma</th>
        <th>Laikas</th>
    </tr>
<?php
    $i = mysql_num_rows($aukciono_istorija1_while);
    $apa = $r1['aukciono_id'];
    $aukciono_istorija2_while = mysql_query("SELECT tab.id, tu.level, tab.user_id, tab.user, tab.bid, tab.date, tab.aukciono_id FROM tb_aukciono_istorija tab JOIN tb_users tu ON tab.user_id = tu.id
    WHERE aukciono_id = $apa ORDER BY tab.id DESC LIMIT 10");
    while ($r2 = mysql_fetch_assoc($aukciono_istorija2_while)) { ?>
        <tr>
            <td><?php echo $r2['aukciono_id']; ?></td>
            <td><?php echo $r2['user']; ?></td>
            <td><?php echo $r2['level']; ?> lvl.</td>
            <td><?php echo $r2['bid']; ?> Eur</td>
            <td><?php echo date('H:i:s', strtotime($r2['date'])); ?></td>
        </tr>
<?php
        $i--;
    }
}
?>
</table>

You have only one table generated by the loop, you should build all the possible tables inside the loop, and give each table a different id related to the aukciono_id, then in the on hover function, get the target aukciono_id and show the table related to this id. try this:

<?php

$aukciono_laimetojai_ir_aukciono_istorija_while = mysql_query("SELECT taw.id AS taw_id,
    tai.aukciono_id AS tai_aukciono_id, taw.user_id AS taw_user_id, taw.win AS taw_win,
    tai.date AS tai_date, taw.date AS taw_date, COALESCE(SUM(tai.bid), 0) AS tai_bid
    FROM tb_auction_winners taw JOIN tb_aukciono_istorija tai
    ON taw.id = tai.aukciono_id
    WHERE tai.user_id = 206 GROUP BY aukciono_id");

$aukciono_istorija1_while = mysql_query("SELECT tab.id, tu.level, tab.user_id, tab.user,
    tab.bid, tab.date, tab.aukciono_id FROM tb_aukciono_istorija tab JOIN tb_users tu
    ON tab.user_id = tu.id
    WHERE tab.aukciono_id = 47 ORDER BY tab.id DESC");

?>
<table>
<?php
while ($r1 = mysql_fetch_assoc($aukciono_laimetojai_ir_aukciono_istorija_while)) {
    if ($r1['taw_user_id'] == 206) { ?>
    <tr>
        <td><?php echo $r1['taw_date']; ?></td>
        <td><?php echo $r1['taw_win'] - $r1['tai_bid']; ?> Eur</td>
        <td>0 Eur</td>
        <td class="placiau" data-aukciono-id="<?php echo $r1['tai_aukciono_id']; ?>">Plačiau <?php echo $r1['tai_aukciono_id']; ?></td>
    </tr>
<?php
    } else { ?>
    <tr>
        <td><?php echo $r1['tai_date']; ?></td>
        <td>0 Eur</td>
        <td><?php echo $r1['tai_bid']; ?> Eur</td>
        <td class="placiau" data-aukciono-id="<?php echo $r1['tai_aukciono_id']; ?>">Plačiau <?php echo $r1['tai_aukciono_id']; ?></td>
    </tr>
<?php
    }
}
?>
</table>
<?php
    while ($r1 = mysql_fetch_assoc($aukciono_istorija1_while)) { ?>
<table class="aukciono_apzvalga" data-aukciono-id="<?php echo $r1['aukciono_id']; ?>" style="
    width: 69.7%;
    left: 632px;
    position: absolute;
    top: 590px;
    z-index: 1;
    opacity: 0;
    -webkit-transition: opacity .5s ease-out;
    transition: opacity .5s ease-out;
    display: block;
    overflow-y: auto;
    max-height: 480px;">
    <tr>
        <td><?php echo $r1['aukciono_id']; ?></td>
    </tr>
</table>
<?php } ?>
<script>
    $('.placiau').hover(function() {
        var aukciono_id = $(this).attr('data-aukciono-id');
        $('.aukciono_apzvalga[data-aukciono-id="'+aukciono_id+'"]').css('opacity', 1);
    }, function() {
        $('.aukciono_apzvalga').css('opacity', 0);
    });
</script>