Jump to content

Table wont display properly


GhostElite_89

Recommended Posts

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>

 

Link to comment
Share on other sites

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

  1. There are no opening/closing TR tags for the header cells
  2. There is no closing tag for the TBODY opening tag
  3. There are TWO closing TABLE tags (for the one table)
  4. There is an extra closing DIV tag compared to the number of opening DIV tags you have posted
Link to comment
Share on other sites

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 by Strider64
Grammar in instead of it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.