GhostElite_89 Posted February 17, 2020 Share Posted February 17, 2020 I have a table that needs to display data and its formatting should allow a scroll bar after a bit of length. In this case, the below code seems to allow it to continue well past the footer of the page... Did I miss something obvious? <div class="col-md-12"> <div class="card card-plain"> <div class="header"> <h4 class="title">Current Vendors</h4> <p class="category">Vendors listed as active within VendorBase.</p> </div> <?php $con=mysqli_connect("localhost","root","test","vendors"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM vendor_data"); echo " <div class='content table-responsive table-full-width'> <table class='table table-hover'> <thead> <th>Name</th> <th>Type</th> <th>Company</th> <th>Email</th> <th>SOC2 Report</th> <th>Status</th> </thead> <tbody>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['type'] . "</td>"; echo "<td>" . $row['company'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['soc'] . "</td>"; echo "<td>" . $row['status'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; mysqli_close($con); ?> </table> </div> </div> </div> Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 17, 2020 Share Posted February 17, 2020 With all due respect, I'm not going to try and learn your code and THEN generate what the output would be to determine what the problem is. We don't have your database to try and create the HTML that would be generated from that code. If you have a problem with the HTML that is generated, you should first look at the HTML. Then, once you find the problem, you can go back to your code that generates the HTML and determine the fix. Create a complete page with a few records and then post the HTML. I assume you have certain style properties on one or more divs to implement the scroll bar, but I dont' see that in your code. So, it's hard to know what the real problem is. I do however, see things that are wrong in the code There are no opening/closing TR tags for the header cells There is no closing tag for the TBODY opening tag There are TWO closing TABLE tags (for the one table) There is an extra closing DIV tag compared to the number of opening DIV tags you have posted Quote Link to comment Share on other sites More sharing options...
gw1500se Posted February 17, 2020 Share Posted February 17, 2020 Here is a handy tool to validate your HTML. Quote Link to comment Share on other sites More sharing options...
Strider64 Posted February 17, 2020 Share Posted February 17, 2020 (edited) I usually do a mockup of my HTML/CSS before implementing PHP that way if I run into problems I know the likely culprit is my PHP code. Heres a small CMS that I did for my website: <div id="gallery" class="picture-box" data-total="<?php echo count($journal); ?>" data-current="" > <?php $counter = 1; foreach ($journal as $records) { $cms = (object) $records; echo '<article class="cms" id="page' . $counter . '">' . "\n"; echo '<h2>' . $cms->heading . '<span class="subheading">by ' . $cms->author . ' on ' . $cms->date_added . '</span></h2>' . "\n"; echo '<a class="myLightBox" id="image' . $counter . '" href="' . $cms->image_path . '" title="Picture Gallery" data-picture="' . $counter . '" data-exif="' . (($cms->Model) ? $cms->Model . ' --- ' . $cms->FocalLength . ' ' . $cms->Aperture . ' ' . $cms->ISO . ' ' . $cms->ExposureTime : null) . '">' . '<img class="blogBox" src="' . $cms->thumb_path . '" alt="Picture for Journal Entry">' . "</a>\n"; echo "<hr>\n"; echo '<p>' . nl2br($cms->content) . "</p>\n"; echo '</article>' . "\n"; $counter += 1; } ?> </div> And you can see the results on my website link: I find it it much simpler and less frustrating to do it this way. BTW that is basically what is said in the other responses. Edited February 17, 2020 by Strider64 Grammar in instead of it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.