0

I want to display an image from a database in my Bootgrid table, and I know that I have to use formatters. But I don't know how? Here is an example of my Bootgrid table and side server code:

var productTable = $('#data').bootgrid({
    ajax: true,
    rowSelect: true,
    post: function () {
        return {
            id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
        };
    },
    url: "load_data.php",
    formatters: {
        "commands": function (column, row) {
            return "<button type='button' class='btn btn-warning btn-xs update' data-row-id='" + row.book_id + "'>Edit</button>" + "&nbsp; <button type='button' class='btn btn-danger btn-xs delete' data-row-id='" + row.book_id + "'>Delete</button>";
        },
    }
});

Here is my server-side code:

$query .= "SELECT book.data_id, 
                  category.category_name, 
                  book.data_name, 
                  book.data_quotes, 
                  book.image 
           FROM product 
           INNER JOIN category 
           ON category.category_id = book.category_id ";

Here is the thing: I receive the data from my PHP file in JSON data type (json_encode), and that puts me in a much worse position.

CDspace
  • 2,639
  • 18
  • 30
  • 36
  • What format is the image in while it's in the database? Is it raw jpg/png/etc data? Is it a path to the actual image file? – Andrew Myers Sep 06 '17 at 17:50
  • well i think the extension doesn't matter,right? in the serverside i json encode the image and i want to fetch it using bootgrid ajax – Husen Al-malik Sep 07 '17 at 03:29
  • Correct, I don't really care about the extension. What I'm trying to figure out is what the stuff in the database _is_. When you put the image in the database, is it the raw image data that goes in the database, or is it a path to the image? If you `console.log(row.book_img)` inside the formatter, what comes out? Is it a bunch of meaningless characters? – Andrew Myers Sep 07 '17 at 13:45

0 Answers0