php - How can I have search results fill the page?
Get the solution ↓↓↓I created my own search function on our website. It uses a simple php script that searches through our database to find what the users are looking for. The search results page doesn't fill the width of the page and the results are displayed vertically, one by one.
The code that displays the results.
$count = 0;
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$t = $count%3;
echo ($t == 2) ? "<div class='col-md-4'>" : "<div class='col-md-4'>";
echo "<div class='card mb-4 shadow-sm'>";
echo "<img class='img-thumbnail' width='300px' src='".$row['image']."'>";
echo "<div class='card-body'>";
echo "<p class='card-text'>".$row['title'] ."<br>".$row['isbn']."</p>";
echo "<div class='d-flex justify-content-between align-items-center'>";
echo "<div class='btn-group'>";
echo "<a href='".$row['url']."'>Start Reading</a>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
$count++;
How can I get the results to fill the width of the page?
Answer
Solution:
I think that you have a few experiece working with the front-end or client side (html, css, javascript).
I see that you only usesdiv
containers, i recomend you see the diferences between inline and block html's elemtens.
Thediv
is an block element that always starts on a new line and takes up the full width available.
An inline element does not start on a new line and only takes up as much width as necessary. An example is thespan
tag.
You should read these articles:
https://www.w3schools.com/html/html_blocks.asp
https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
Also i recomend you to learn how to use the navigator console that show you the with and height of all of your html tags and more util information.
Answer
Solution:
It seems you are using Bootstrap CSS framework. If you want to keep using that, you might want to understand how the grid works by reading this page: https://getbootstrap.com/docs/4.5/layout/grid/
I didn't test your code, but the fact that you are using the classcol-md-4
is probably why it's not taking the whole width of the page (the result depends on the parent container of the code you are generating, which you didn't show).
So go ahead and remove the classcol-md-4
to see what happens.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the process class relies on proc_open, which is not available on your php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.