lundi 18 octobre 2021

How to save html code with if condition in database

I have a rating field in the database. If the value of $rating>0, the button should be disabled otherwise button should be enabled.I am saving the HTML code to database to dispaly.

What I have tried is :

 $user_notification->notification ="Delivery date <b>" .$date."</b> and delivery time <b> ".$time." </b> for the truck " .$truck_name. " of mileage ".$mileage_name. " of quantity ".$qty. " has confirmed 
        <br> <a href='#' class='btn btn-primary' >Pay ?</a>
        if(.$rating.'=='.0.'){<a href='/showTransaction/".$buy_id."' class='btn btn-primary' >Review ?</a>}else{<a href='' class='btn btn-primary' disabled >Review ?</a>}";
         $user_notification->save();

The data is saving but What I get in my output as:

Output

How to avoid if and else from showing in html?

Aucun commentaire:

Enregistrer un commentaire