So I have this html table, and it's spilling everywhere on the screen.

Started by rcane, May 20, 2022, 03:25:32 PM

Previous topic - Next topic

rcane

I've got an html table on a php page that's using the header() and footer() of the theme.

But, I've given it too many rows and the table is now spilling over into the footer.

Before I start plastering code all over here, are there any come-to-minds that would head this off?You cannot view this attachment.

Doug Heffernan

Quote from: rcane on May 20, 2022, 03:25:32 PMBefore I start plastering code all over here, are there any come-to-minds that would head this off?

It is hard to say without seeing the code.

rcane

Quote from: Doug Heffernan on May 20, 2022, 04:11:50 PM
Quote from: rcane on May 20, 2022, 03:25:32 PMBefore I start plastering code all over here, are there any come-to-minds that would head this off?

It is hard to say without seeing the code.


Ok. Ran an errand. I'll past the page code when I get home

rcane

I'm thinking this might be more of a coding thread than 2.0.19 thread.

<?php

//verify you're approved from mySite to view this 
include_once("/home/linuxUser/public_html/myDomain.com/SSI.php"); //LOAD SSI
include_once("/home/linuxUser/public_html/myDomain.com/Docs/courtfilings/db.php");

 
template_header();
     
if ( (!
in_array(1$user_info['groups'])) && (!in_array(2$user_info['groups'])) && (!in_array(0$user_info['groups'])) && (!in_array(13$user_info['groups']))     ) {


echo 
"Sorry, but you are not permitted to view this.  Redirecting..."//DENIAL MESSAGE
header('Refresh: 2; URL=http://myDomain.com/');
die;

}
     
$results = array();
     
     
$gather $conn->query("SELECT * FROM courtfilings ORDER BY file_number DESC"); //get all records and order them
       
while($row $gather->fetch_object()) { //get 
            
$results[] = $row
            } 

?>



<!DOCTYPE html>
<html>
  <head>
    <title>Court Filings</title>
  <meta charset="utf-8" name="viewport"
        content= "width=device-width, initial-scale=1.0">
    <style>
   
      table, th, td {
  border: 1px solid grey;
}
      body {
        margin: 0;
      }
      .navbar {
        overflow: hidden;
        background-color: #0000c5;
        position: fixed;
        top: 0;
        width: 100%;
       
      }
      .navbar a {
        float: left;
        display: block;
        color: #ffffff;
        text-align: center;
        padding: 15px 18px;
        text-decoration: none;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 18px;
      }
      .navbar a:hover {
        color: #00ccff;
      }
      .container {
        padding: 18px;
        margin-top: 35px;
        height: 2000px;
      }
    </style>
  </head>
  <body>



<div class="container">
 <?php if (in_array(1$user_info['groups']) || in_array(2$user_info['groups'])) : ?>
 <button class="favorite styled" type="button"><a href="http://myDomain.com/Docs/courtfilings/create.php">Upload a new court doc</a></button>
<br><br>
<?php endif; ?>

 <center><h1>All Court Filings</h1></center><br>
 <center><h2>(in order from the most recent)</h2></center>
 <br>
 
  <table align="center" class="table users" style="width:90%">
            <thead>
                <tr>
                    <th id="top" style="background-color:lightgrey; width:10%; padding: 5px" ><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>Upload #</th>
                    <th style="background-color:lightgrey; width:10%" ><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>Filing Date</th>
                    <th style="background-color:lightgrey;"><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>File Description</th>
                       
                        <?php if (in_array(1$user_info['groups']) || in_array(2$user_info['groups'])) : ?>
                        <th style="background-color:lightgrey; width:10%"><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>Delete?</th>
                       <?php endif; ?>
                </tr>
            </thead>
            <tbody>
                <?php foreach ( $results as $result ) : ?>
               
                    <tr>
                        <td align="center"><?php echo $result->file_number?></td>
                        <td align="center" style="padding: 7px"><?php echo $result->file_date?></td>
                        <td align="left" style="padding: 15px"><a target="_blank" href = <?php echo "https://myDomain.com/Docs/courtfilings/files/" $result->file_actual?>><?php echo $result->file_description?></td>
                      
                       <?php if (in_array(1$user_info['groups']) || in_array(2$user_info['groups'])) : ?>
                        <td align="center"><a class="btn btn-danger" href="confirmdelete.php?id=<?php echo $result->file_number?>"><img src="deleteButton.png" height=30 width=30></a></td>
                       <?php endif; ?>
                    </tr>
                <?php endforeach; ?>
            </tbody>
            <tfoot>
                <tr>
                    <th style="background-color:lightgrey;" ><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>Upload #</th>
                    <th style="background-color:lightgrey;"><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>Filing Date</th>
                    <th id="bottom"style="background-color:lightgrey;" ><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>File Description</th>
                     <?php if (in_array(1$user_info['groups']) || in_array(2$user_info['groups'])) : ?>
                        <th style="background-color:lightgrey; width:10%"><FONT COLOR=Black FACE="Geneva, Arial" SIZE=2>Delete?</th>
                       <?php endif; ?>
                </tr>
            </tfoot>
        </table>
  
   
  </body>
</html>


<?php template_footer(); ?>

Arantor

Firstly, ditch all of the <html>, <head>, <title>, <body> and their respective closing tags - all of that is covered by template_header(). You can have just the <style> tag, that's fine.

The real kicker is that you have a <div> open before the content and no closing </div> after your table. But getting rid of the actually-invalid tags (because you have a document inside a document) will also help.

Doug Heffernan

Quote from: rcane on May 20, 2022, 05:21:30 PMI'm thinking this might be more of a coding thread than 2.0.19 thread.

I agree. I moved it to the SMF Coding Discussion board.

Additionally, I noticed that you are using depricated tags as well, like the <center></center> tags.

rcane

Quote from: Arantor on May 20, 2022, 05:26:43 PMFirstly, ditch all of the <html>, <head>, <title>, <body> and their respective closing tags - all of that is covered by template_header(). You can have just the <style> tag, that's fine.

The real kicker is that you have a <div> open before the content and no closing </div> after your table. But getting rid of the actually-invalid tags (because you have a document inside a document) will also help.

Cleaned up the tags, but the <div> was the one.  Thank you.

Next time I'll try to keep the language current and make it more MVC.

Advertisement: