A
A
ART42020-08-13 11:10:36
PHP
ART4, 2020-08-13 11:10:36

Why are HTML tags being output from JSON as is and not being rendered?

Good afternoon, how is the output from mysqli processed data with tags with html markup?
5f34f4b410819915065555.jpeg
Is derived from the database: And it is necessary that it be displayed Development and support of sites Data output comes from the database in JSON php
Разработка и поддержка <b>сайтов</b>


<?php
    header('Content-Type: text/html; charset=utf-8');
    header('Access-Control-Allow-Origin: *');
    include 'DBConfig.php';

    $link = mysqli_connect($HostName, $HostUser, $HostPass, $DatabaseName) or mysql_query("SET NAMES 'UTF-8'"); // Соединяемся с базой


    // Ругаемся, если соединение установить не удалось
    if (!$link) {
    echo 'Не могу соединиться с БД. Код ошибки: ' . mysqli_connect_errno() . ', ошибка: ' . mysqli_connect_error();
    exit;
    }
    
    //Само собой, КОДИРОВКА 
    mysqli_query($link, 'SET names UTF8');

    //Сам запрос в базу MySQL
    $sql = mysqli_query($link, "SELECT * FROM service WHERE id>0 ORDER BY status DESC, id DESC");
    
    //МАССИВ JSON
    $functions = [];
    
    // Обход каждого элемента и добавление в Массив
    while ($result = mysqli_fetch_array($sql)) {
        $functions[] = $result = [
            id => $result["id"], 
            name => $result["name"], 
            email => $result["email"], 
            thumbnailUrl => $result["thumbnailUrl"], 
            phone => $result["phone"], 
            category => $result["category"], 
            category_id => $result["category_id"],
            parent_id => $result["parent_id"],
            announce => $result["announce"],
            status => $result["status"],
            rating => $result["rating"],
            visible => $result["visible"]
        ];

    }

    //Вывод jSON
    $json = json_encode($functions, JSON_UNESCAPED_UNICODE);
    echo htmlspecialchars_decode($json, ENT_HTML5);
?>


In the database:
5f34f5372eb2e505409997.jpeg
5f34f54de3a74976631559.jpeg

How is this issue resolved? Already broke my head

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-08-13
@ART4

The question has nothing to do with the database (and even more so with mysqli, in which nothing can be stored in principle).
Understand how you display this jason with javascript on the client

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question