S
S
Sergey2017-11-07 18:22:54
PHP
Sergey, 2017-11-07 18:22:54

Does Google have api that allows you to display such cards on your site (as in the screenshot)?

Does Google have api that allows you to display such cards on your site (as in the screenshot)? Let's say I have a search box from Google directly on the site, I will drive in a request, and under this line I will see such a card.5a01cf71b4c93853006896.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
irishmann, 2019-08-14
@Motchanyy

Hold
<?php
    /* создаем соедиенение с бд*/
    $link = mysqli_connect("localhost", "root", "", "test");

    /* для примера возьмем такой doctorid*/
    $doctorid = 2; 

    /* создаем подготавливаемый запрос */
    $stmt = mysqli_stmt_init($link);
    $sql = '
        SELECT
            cal.`doctorid`,
            doc.`doctor-name`,
            cal.`clinicid`,
            clin.`clinic-name`,
            cal.`start`,
            cal.`end`
        FROM
            `bio_vet_calendar` cal 
            JOIN `bio_vet_clinic_department` clin ON cal.`clinicid` = clin.`clinicid`
            JOIN `bio_vet_doctor` doc ON cal.`doctorid` = doc.`doctorid`
        WHERE
            cal.`doctorid` = ?
    ';
    if (mysqli_stmt_prepare($stmt, $sql)) {
        /* привязываем переменные к параметрам */
        mysqli_stmt_bind_param($stmt, "i", $doctorid);
        /* выполняем запрос */
        mysqli_stmt_execute($stmt);
        /* выбираем данные из результата */
        $response = mysqli_stmt_get_result($stmt);
        /* преобразовываем в ассоциативный массив*/
        $result = mysqli_fetch_all($response, MYSQLI_ASSOC);
        /* закрываем запрос */
        mysqli_stmt_close($stmt);
    }
    
    /* закрываем соединение с бд*/
    mysqli_close($link);
    
    /* выводим JSON */
    echo json_encode($result);

Only connection with a DB correct on the.

F
FanatPHP, 2019-08-14
@FanatPHP

Answer to the question How to withdraw:
But the problem is that you don't have any data yet, you haven't made a request yet.
To learn how to write a query that returns the desired data, ask a separate question.

I
Igor, 2019-08-14
@IgorPI

If you want a complex structure in the form of a hierarchy, use an ORM.
It seems to me that it is even faster and better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question