remove first h3 tag and br tags in text

I have text that is displayed from a database and I have managed to remove the first h3 tag in the text by using the following code but I would also like to remove the two <br> tags that are before the paragraph of text

<h2 class="productsummaryheading mb-0">Product Summary</h2>
              <?php
$html= substr($description,0,strrpos(substr($description,0,300)," "));
$final = preg_replace('#<h3>(.*?)</h3>#', '', $html, 1);
echo $final;
?> ...<a href="<?php echo $_SERVER["REQUEST_URI"]; ?>#productdescription">Read More</a>

A example of the text paragraph is below

<br />          <br />  This 11.6 Chromebook is light, portable, rugged, and productive  the ultimate everyday learning tool. It brings Google Classroom, G Suite for Education, and todays ...<a href="/shop/laptops-tablets/Laptops/lenovo-100e-chromebook-g2-laptop-11-6-celeron-n4020-4gb-32gb-emmc-webcam-wi-fi-no-lan-usb-c-chrome-os#productdescription">Read More</a>

Display specific html tag on specific pages

I want to display different html tags on the php page they are visiting, for example on the homepage and the computer shop basildon page I want the html tag <section class="testimonal-two pt-0"> and on all other pages I want the code <section class="testimonal-two">

Below is the code I have so far and it works for the computer shop basildon page but I'm unsure how to add the homepage into that code, the homepage is called index.php

<?php
if ($_SERVER["SCRIPT_NAME"] == '/computer-shop-basildon.php') {
    echo '<section class="testimonal-two pt-0">';
} else {
    echo '<section class="testimonal-two">';
}
?>

check if date in database has passed todays date

I am in the middle of making a web based system for shows and each show as a different closing date for entries. The closing date is stored in a database. I need to display a export to excel button once the closing date has passed for each show.

I have already done the export to excel button and that works but it's clickable all the time, I need the button to only be clickable once the closing date for each show has passed. I'm thinking I need to check if the closing date in the database has passed compared to todays(current) date.

Not sure how it would work if each show has a different closing date though?

Below is what I came up with but know it's way off

<?php
$sql="SELECT closing_date FROM shows";
$result1 = mysqli_query($mysqli, $sql);
while($info = mysqli_fetch_assoc($result1)){
if(date('Y-m-d') > $info['closing_date'] ){
echo '<input type="submit" name="export_excel" class="btn btn-success float-md-right" value="Export to Excel">';
break;
}
elseif(date("Y-m-d") < $info['closing_date'] ){
echo '<a href="javascript:void(0);"><input type="submit" name="export_excel" class="btn btn-dark float-md-right" value="Export to Excel"></a>';
break;
}
}
?>

time difference in php mysql

I have a database that has columns called start date, start time, end date and end time and want to be able to output the difference so it shows the total time spent per project. Below is the code I have but it shows the error PHP Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (15/08/2021 10:48 AM) at position 0 (1): Unexpected character in view-specific-repair.php:258

On line 258 is the line below

$datetime1 = new DateTime($row->exstdate . ' ' . $row->exstime);

The whole code is below

<?php                                            
$datetime1 = new DateTime($row->exstdate . ' ' . $row->exstime);
$datetime2 = new DateTime($row->exrdate . ' ' . $row->extrime);

$interval = $datetime1->diff($datetime2);?>
Time Spent: <?php echo $interval->format('%Y years, %M months, %D days, %I minutes, %S seconds');?>

I'm not sure what to change it to so it works and outputs the time spent between the start date and start time to the end date and end time

limit to 1 per where or clause

I have managed to get blog posts displayed from each blog category but I want to limit it to 1 article from each blog category but unsure how to do it in the sql query I have, below is what I have so far

(SELECT BP.postID,postTitle,postSlug,postDesc,postDate,postImage
        FROM 
          blog_posts BP, blog_post_cats BPC 
    WHERE 
       BPC.catID = 6 AND BPC.postID = BP.postID OR BPC.catID = 5 AND BPC.postID = BP.postID OR BPC.catID = 4 AND BPC.postID = BP.postID OR BPC.catID = 1 AND BPC.postID = BP.postID
     )
    UNION
    (SELECT BP.postID,postTitle,postSlug,postDesc,postDate,postImage
        FROM 
          blog_posts BP, blog_post_cats BPC
    WHERE 
       BPC.catID = BPC.postID = BP.postID
     )

php code help for data output

I am trying to output data for selected dates and think I have managed to do the sql query but it's currently not outputting the total amount, below is what it is currently outputting

I am looking for the following

From To Expense Category Expenses Total
01/01/2018 31/12/2018 Accounting Costs 0.00
01/01/2018 31/12/2018 Marketing 0.00

Below is the current code I have

<?php
            if (isset($_POST['submit'])){
                include('dbconnection.php');
                $from=date('Y-m-d',strtotime($_POST['from']));
                $to=date('Y-m-d',strtotime($_POST['to']));

                $oquery=$mysqli->query("SELECT ec.expense_category_id, ec.expense_category_name,sum(e.expenseamount), date_format('$from','%d/%m/%Y') as `from`, date_format('$to','%d/%m/%Y') as `to` FROM expenses e join expense_category ec ON e.expense_category_id = ec.expense_category_id WHERE e.expddate between '$from' and '$to' group by ec.expense_category_name");

                if ($oquery->num_rows > 0) {
                while($orow = $oquery->fetch_array()){

                ?>

                <tr>
                        <td><?php echo $orow['from'] ?></td>
                        <td><?php echo $orow['to'] ?></td>
                        <td><?php echo $orow['expense_category_name'] ?></td>
                        <td><?php echo "" . '&#163;' . number_format($orow['expenseamount'], 2) . "";?></td>
                    </tr>
                    <?php 
                    }
                } else {
                    echo "0 Results";
                }
            }
        ?>

Can someone help please as I'm not 100% on PHP, I'm not sure if is to do with my sql query or is something else?

unable to retrieve data for one column

I have some php code on view invoice and it's getting all the data I need to from three database tables but for some reason it's not getting the data for one specific column and unsure why

I have done a echo sql and it is echoing the sql query ok and have ran the sql query in phpmyadmin and is displaying the column in phpmyadmin that is not displaying on the php page so am bit confused, below is the coding I have. I took out a lot of it and tried to keep to the relevant parts

<?php
$sql = "SELECT t1.id, t1.invoice_number, DATE_FORMAT(t1.invoice_date,'%d/%m/%Y') AS invoice_date, t1.user_id, t2.invoice_number, t2.service_name, t2.service_price, t3.user_id, t3.customer_name, t3.customer_phone, t3.customer_email, t2.service_name, t2.service_price, t1.invoice_total, t1.balance, t1.notes, DATE_FORMAT(t1.payment_date,'%d/%m/%Y') AS payment_date, t1.payment_method
FROM invoices as t1
LEFT JOIN invoice_products as t2
ON t1.id = t2.invoice_id
LEFT JOIN users as t3
ON t1.user_id = t3.user_id
WHERE t1.user_id = '".$_SESSION['user_id']."' and t1.id = '".$_GET['id']."'";

$result = mysqli_query($connect, $sql);

                if(mysqli_num_rows($result) > 0)
                {
                if($row = mysqli_fetch_array($result))  
                {
                ?>

                Notes: <?php echo $row['notes'];?>

                <?php
                    }
                    }
                    ?>