Displaying Row data

{ “_id”: “KaIFTRaBv59T”, “content”: “Always seek out the seed of triumph in every adversity.”, “author”: “Og Mandino”, “tags”: [ “Famous Quotes”, “Wisdom” ], “authorSlug”: “og-mandino”, “length”: 55, “dateAdded”: “2019-06-13”, “dateModified”: “2023-04-14” }

Displaying Data in HTML format

m6XgvIBvOZTs
They can do all because they think they can.
Virgil
Famous Quotes
virgil
44
2020-12-06
2023-04-14

Displaying Only required Data

A ruffled mind makes a restless pillow.
2021-01-19

Link

A lot of times people look at the negative side of what they feel they can’t do. I always look on the positive side of what I can do.

Displaying quotes Using PHP code

Author Quote Length
Charles Dickens No one is useless in this world who lightens the burdens of another. 68
Charles Dickens Minds, like bodies, will often fall into a pimpled, ill-conditioned state from mere excess of comfort. 102
Charles Dickens Subdue your appetites, my dears, and you've conquered human nature. 67
Charles Dickens Reflect on your present blessings, of which every man has many; not on your past misfortunes, of which all men have some. 121
Charles Dickens I do not know the American gentleman, god forgive me for putting two such words together. 89

Code Used to create table above. The code is added on code Snippet as “Quotable Quotes Table”

function display_quotable_quotes() {
    // Fetch data from the wpgetapi endpoint
    $data = wpgetapi_endpoint('quotable', 'quotes', array('debug' => false));

    // Initialize output variable
    $output = '';

    // Check if we have the correct data
    if (isset($data['results']) && is_array($data['results'])) {
        // Start table HTML
        $output .= '<table class="table table-bordered">
                        <thead>
                            <tr>
                                <th scope="col">Author</th>
                                <th scope="col">Quote</th>
                                <th scope="col">Length</th>
                            </tr>
                        </thead>
                        <tbody>';

        // Loop through each item in the results array
        foreach ($data['results'] as $item) {
            $output .= '<tr>
                            <td>' . esc_html($item['author']) . '</td>
                            <td>' . esc_html($item['content']) . '</td>
                            <td>' . esc_html($item['length']) . '</td>
                        </tr>';
        }

        // End table HTML
        $output .= '</tbody></table>';
    } else {
        // If no data is found, display a message
        $output .= '<table class="table table-bordered">
                        <tr>
                            <td colspan="3">No quotes were found.</td>
                        </tr>
                    </table>';
    }

    // Return the output
    return $output;
}

// Register the shortcode
add_shortcode('quotable_quotes', 'display_quotable_quotes');

Display Images

Code Used to create Images. The code is added on code Snippet as “Pixabay Display”

// Function to enqueue the required scripts and styles
function enqueue_fotorama_assets() {
    // jQuery
    wp_enqueue_script('jquery');
    // Fotorama CSS
    wp_enqueue_style('fotorama-css', 'https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.css');
    // Fotorama JS
    wp_enqueue_script('fotorama-js', 'https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.js', array('jquery'), null, true);
}
add_action('wp_enqueue_scripts', 'enqueue_fotorama_assets');

// Function to display images from the Pixabay API
function display_pixabay_images() {
    // Fetch data from the wpgetapi endpoint
    $data = wpgetapi_endpoint('pixabay', 'api', array('debug' => false));

    // Initialize output variable
    $output = '';

    // Check if we have the correct data
    if (isset($data['hits']) && is_array($data['hits'])) {
        // Start fotorama div
        $output .= '<div class="fotorama" data-nav="thumbs">';

        // Loop through each image in the hits array
        foreach ($data['hits'] as $image) {
            $output .= '<img src="' . esc_url($image['webformatURL']) . '" />';
        }

        // End fotorama div
        $output .= '</div>';
    } else {
        // If no data is found, display a message
        $output .= '<p>No images were found.</p>';
    }

    // Return the output
    return $output;
}

// Register the shortcode
add_shortcode('pixabay_images', 'display_pixabay_images');

Display quotes

No one is useless in this world who lightens the burdens of another.

Charles Dickens

Minds, like bodies, will often fall into a pimpled, ill-conditioned state from mere excess of comfort.

Charles Dickens

Subdue your appetites, my dears, and you've conquered human nature.

Charles Dickens

Reflect on your present blessings, of which every man has many; not on your past misfortunes, of which all men have some.

Charles Dickens

I do not know the American gentleman, god forgive me for putting two such words together.

Charles Dickens

Inserting Data to Database Table and displaying form the Table

[stored_quotes]

WPForms Contact

Please enable JavaScript in your browser to complete this form.

Contact form 7

    Displaying Data

    Table 1

    Displaying Data in a Data table from Hubsport CMS API showing contact list.

    createdate email firstname hs_object_id lastmodifieddate lastname
    06/06/2024 08:42 AM user2@gmail.com user2 17.468.823.482 06/06/2024 08:43 AM
    06/06/2024 08:45 AM user1@gmail.com user1 17.468.825.314 06/06/2024 08:46 AM
    06/06/2024 10:40 AM nikunj+1@wpgetapi.com nikunj 17.491.356.859 06/06/2024 10:40 AM
    06/06/2024 10:13 AM nikunj@wpgetapi.com Nikunj 17.495.285.726 06/06/2024 10:13 AM
    07/06/2024 07:22 AM 17.686.675.393 07/06/2024 07:23 AM
    13/06/2024 08:06 AM test@gmail.com test 18.764.418.760 13/06/2024 08:06 AM
    Generated by wpDataTables

    Table 2

    Displaying Data in a Data table from Dad Jokes API showing it in a table.

    _id setup punchline type approved date NSFW shareableLink
    60dd35b43b8b728bc153382e I told my psychologist I am scared off living in tall buildings Apparently it’s an Apartment Complex building 1 1.618.108.661 https://dadjokes.io/joke/60dd35b43b8b728bc153382e
    Generated by wpDataTables

    ChatGPT

    Please enable JavaScript in your browser to complete this form.