The power of PHP's echo function comes alive as it seamlessly connects

I am currently working on developing a product catalog using PHP. Below is the HTML flex-container code:

<div class="products">
        <?php
        echo file_get_contents("http://192.168.64.2/CodeWay/Pages/product.php");
        ?>
        </div>

The PHP code retrieves all the available courses from the database and displays them in the container as follows:

 require_once '../Backend/Config.php';
    $query = "SELECT * FROM `products` ORDER BY `product_id`";
    $result = $link->query($query);

    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            echo "<div class='product-flex-item'>";
            echo $row["product_name"];
            echo "<div> <br>";
        }
}

However, after echoing the flex-items, the flex-container appears like this:

<div class="products">
        <div class='product-flex-item'>php beginner course<div> <br><div class='product-flex-item'>cascca<div> <br></div>

Unfortunately, the display is not correct. The second item appears smaller than the first one, and attempting to set justify content to space between fails to make any changes.

Answer №1

Correction needed: echo "<div> <br>"; should be changed to echo "</div> <br>";

The issue lies in not properly closing the initial div tag, causing them to nest incorrectly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Integrate HTML parsing both inside and outside of an iframe using BeautifulSoup

My current project involves web scraping a real estate listing platform using Selenium, BS4, and Python. The script works by fetching the links to each listing page before proceeding to parse the HTML content of those pages. One key component is a Chrome E ...

Creating evenly spaced PHP-generated divs without utilizing flexbox

My goal is to display images randomly from my image file using PHP, which is working fine. However, I am facing an issue with spacing the images evenly to fill the width of my site. This is how it currently appears: https://i.stack.imgur.com/AzKTK.png I ...

iOS authentication token combining PHP

Currently, I am working on an iOS application that requires user login using a unique user ID and password. The existing flow of the process is outlined below: 1) Users input their user ID and password. 2) Upon clicking the login button, a PHP webservice ...

Selection of checkboxes and utilization of arrays

I currently have a total of 9 check boxes on my select.php page <form method="post" action="test.php"> <input type="checkbox" name="g1[]" id="c1" value="c1"> <input type="checkbox" name="g1[]" id="c2" value="c2"> <input type="checkbox ...

Obtaining Values from Identical jQuery Buttons with the Same Class名称

I am facing an issue with my PHP script that generates buttons for each content schedule. The script outputs multiple HTML buttons with the same name, class, and ID, but their values are dynamically set based on a variable. In my jQuery code, I have selec ...

What is the most efficient way to transfer data from PHP Laravel to Vue.js and automatically update a Vue.js component whenever the data is modified?

New to Vue.js and feeling a bit lost about how reactivity works with it. I want to send data from PHP Laravel to a Vue.js component and have the component update automatically when the data changes. I've come across suggestions on Stack Overflow reco ...

Unable to integrate an if/else statement into the JSON reply

Working with an API to retrieve data and display images from it. I am attempting to implement an if/else statement that will show photos if the search term yields results in the response, and display a message indicating no results if it does not. Curren ...

Could use some assistance in developing a custom jQuery code

Assistance Needed with jQuery Script Creation <div>Base List</div> <div id="baseSection"> <ul class="selectable"> <li id="a">1</li> <li id="b">2</li> <li id="c">3</li> ...

PHP, jQuery, and MySQL combine to create a powerful autocomplete feature for your

I've implemented the source code from into my project, but I'm facing an issue where I can't retrieve any results when typing in the autocomplete textbox. Could someone point out where I might be making a mistake? This is the code I am us ...

Strategies for managing sluggish server responses while monitoring a plethora of feeds

How can I effectively manage the task of checking hundreds of RSS/Atom feeds using PHP and updating a MySQL database with new items? The script runs on a cron daemon at specified intervals. One challenge I face is that many of the feed servers have slow r ...

What is the best way to add selected values from a multi-select dropdown into an array?

Attempting to populate an array from a multiple select dropdown, I've encountered an issue. Despite using splice to set the order of values being pushed into the array, they end up in a different order based on the selection in the dropdown. For insta ...

Tips for layering one div on top of another div

I'm looking for guidance on how to position my button divs over my Trapezoids in an overlay fashion. Currently, I have set up an array to store the colors and utilizing the map function to match each button with its corresponding color type. When a ...

Using PHP to reset variables for dynamic display in JavaScript

I've been working on retrieving values from a database and storing them in JavaScript variables. While I was successful in accomplishing this task, I encountered an issue when the values in the database are updated - the values of the variables remain ...

"Adding dots" in a slideshow using HTML, CSS, and JS

I'm currently working on a slideshow that includes navigation dots at the bottom. Although the slideshow is functioning properly, I am encountering an issue where only one dot appears instead of the intended three in a row. Despite my research and att ...

Enhance the php function with the latest updates

I am currently working on an update file using PHP and MySQL, but I am encountering issues with the update function not working as expected. I initially wrote the code based on an example and made modifications according to my project requirements. The fil ...

Downloading Excel files in Angular using File Saver

Previously, I had set up a PHP post form that would download an excel file upon clicking the button. The form data was also posted to the URL successfully using plain HTML and submit form. This is the function in PHP that gets triggered when the form is p ...

How to fetch select element within a table by using jQuery

I encountered a situation where I have a table element with a select element inside its td. The id of the table (in this example, it is "table1") could potentially change. So my query is, how can I retrieve the selected option using the table ID in JQuer ...

PHP is experiencing a delay of an additional second in fetching each result set from Sphinx!

After working perfectly fine the night before, I encountered a strange issue today. The problem arose after reinstalling WAMP on my local dev server and attempting to retrieve results from Sphinx using the PHP API. For testing purposes, I executed a basic ...

What is the best way to showcase a div on top of all other elements in an HTML page?

As a newcomer to html and css, I have successfully created a div that contains city names. The issue I am currently facing is when I click on a button to display the div, it gets hidden behind the next section of my page. Take a look at the image below for ...

Transform object into JSON format

Is there a way to transform an object into JSON and display it on an HTML page? let userInfo = { firstName: "O", lastName: "K", email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b44476b445b05484446">[ema ...