How to get multiple rows as variables from different select queries

<?php
include '../includes/dbconnection.php';
?>
<?php

$query = "SELECT SUM(`amount`) AS tdamount
FROM transactions
WHERE date>=DATE_SUB(NOW(), INTERVAL 24 HOUR)";


$query2 = "SELECT SUM(`amount`) AS tdweek
FROM transactions
WHERE date>=DATE_SUB(NOW(), INTERVAL 24 HOUR)";

/*
$stmt = $con->prepare($query);

$stmt->execute();


$queryResults = $stmt->get_result();
//$queryResults2 = $stmt2->get_result();

if($queryResults->num_rows > 0 ){

    while($arrayResults = $queryResults->fetch_assoc()){
     
    
            $tdamount = number_format($arrayResults['tdamount']);
            $tdweek = number_format($arrayResults['tdweek']);

Hello @georgemunganga - welcome to the forums

[off-topic]
When you post code in the forum, you need to format it. To do so you can either select all the code and click the </> button, or type 3 backticks ``` on a separate line both before and after the code block.

I have done it for you this time.
[/off-topic]

Two ways i can think of right now

Union

SELECT SUM(`amount`) AS...
UNION
SELECT SUM(`amount`) AS...

Subqueries

SELECT (
(SELECT SUM(`amount`) AS...),
(SELECT SUM(`amount`) AS...)
)

They are the same exact query’s except for what you are naming the result.

What is the real problem you are trying to solve by doing this? I suspect you also have a DB design problem. It would be a good idea to post an sql dump of your schema.