<?php
include('./dashboard/db_connection.php');
$query_nft_collectible = mysqli_query($con, "SELECT * from pcl_exchange");

while ($fetch_nft_collectible = mysqli_fetch_array($query_nft_collectible)) {
    $nft_collectible_name                 = $fetch_nft_collectible['name'];
    $nft_collectible_logo                 = $fetch_nft_collectible['logo'];
    $nft_collectible_total_sold           = $fetch_nft_collectible['total_sold'];
    $nft_collectible_percentage_change    = $fetch_nft_collectible['percentage_change'];
}
?>

<script>
    const valuePrefix = '$';
    const valuePostfix = 'M';
    let nftCollectibleObj = [];
</script>

<?php
$query_nft_collectible_values = mysqli_query($con, "SELECT * from pcl_exchange");
while ($fetch_nft_collectible_values = mysqli_fetch_array($query_nft_collectible_values)) {
    $name = $fetch_nft_collectible_values['name'];
    $logo = $fetch_nft_collectible_values['logo'];
    $total_sold = $fetch_nft_collectible_values['total_sold'];
    $percentage_change = $fetch_nft_collectible_values['percentage_change'];
?>
    <script>
        nftCollectibleObj.push({
            name: '<?php echo $name ?? null; ?>',
            image: '<?php echo $logo ?? null; ?>',
            value: <?php echo $total_sold ?? null; ?>,
            isValueIncreased: <?php if ($percentage_change > 0) {
                                    echo 'true';
                                } else {
                                    echo 'false';
                                } ?>,
            percentageForLongs: <?php echo $percentage_change ?? null; ?>,
        });
    </script>
<?php
}
?>