0

This is my php code I use. But for on or other reason it doesn't change with my CSS. I keeps on giving it weight of the picture lenght & height. You can see in the screenshot what goes wrong. The HtmlTable of my does change but my doesn't. WORKS -> PHP ERROR CSS -> ERROR

    $htmlTabel = '';
    $htmlTabel .= '<table border="1px">';
    $htmlTabel .= '<tr>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Foto</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Type</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Prijs</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Adres</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Woonopp</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Grondopp</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Slaapkamers</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Badkamers</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Bebouwing</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Bouwjaar</th>';
    $htmlTabel .= '<th style="padding: 10px; padding-right: 35px; padding-left: 35px;">Beschrijving</th>';
    $htmlTabel .= '</tr>';

    for ($i = 1; $i <= $adsId; $i++) {
        $url = "http://localhost:55342/api/tekoop/" . $i; // path to your JSON file
        $data = file_get_contents($url); // put the contents of the file into a variable
        $apidata = json_decode($data); // decode the JSON feed

        $img = "<img src='img/$apidata->images' width='500px' height='500px'></img>";

        $htmlTabel .= '<tr>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $img . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->type . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->prijs . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->adres . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->woonopp . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->grondopp . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->slaapkamers . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->badkamers . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->bebouwing . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->bouwjaar . '</td>' .
                '<td style="padding: 10px; padding-right: 35px; padding-left: 35px;">' . $apidata->text . '</td>' .
                '</tr>';
    }
    $htmlTabel .= '</table>';



    $conn->close();
    ?>

HTML CODE

    <div class="container" style="margin-left:150px; margin-right:150px; font-family:Georgia; margin-top: 75px; text-align: center; ">
        <?php echo $htmlTabel ?>
    </div>
  • I can't seem to reproduce that issue. When I use your code, there's padding on the table cell that contains the image. [Here is the HTML](https://jsfiddle.net/ev4Lbp9k/) that's rendered. It might help to build a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) in your question, without the PHP, to demonstrate. – showdev Jun 17 '19 at 19:05
  • 2
    Although I can't reproduce the problem, it *might* be related to the closing `` tag, which is invalid in HTML. See [How to close tag properly](https://stackoverflow.com/questions/14860492/how-to-close-img-tag-properly) and [Why is the tag not closed in HTML](https://stackoverflow.com/questions/23890716/why-is-the-img-tag-not-closed-in-html/23890817). – showdev Jun 17 '19 at 19:06

0 Answers0