Jump to content

Recommended Posts

I am trying to lock the headers in my table.  I have gotten it to work in html but when i try and echo it in php i get an error

Parse error: parse error, unexpected T_STRING, expecting ',' or ';'

 

Any help

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<?php include ("login.php");?>

 

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

<title>Lock Table Head</title>

 

<style type='text/css'>

 

/* DIV container around table to constrict the height for IE (IE ignores the tbody height style) */

div.FixedTableHead {

overflow-y:auto;

 

/* this fixes IE so container width is same as table width */

width: expression( (this.childNodes[0].clientWidth + 24) + 'px' );

 

/* This fixes IE so the container height is table height plus the height of the header */

height: expression( (parseInt(this.childNodes[0].style.height) + this.childNodes[0].childNodes[1].offsetTop + 1) +'px' );

}

 

/* Scrollable Content */

.FixedTableHead table tbody {

height:100%;

overflow-x:hidden;

overflow-y:auto;

}

 

.FixedTableHead table tbody tr {

height: auto;

white-space: nowrap;

}

 

/* Prevent Mozilla scrollbar from hiding right-most cell content */

.FixedTableHead table tbody tr td:last-child {

padding-right: 20px;

}

 

/* Fixed Header */

/* In WinIE any element with a position property set to relative and is a child of      */

/* an element that has an overflow property set, the relative value translates into fixed.    */

/* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */

.FixedTableHead table thead tr {

position: relative;

height: auto;

/* this fixes IE header jumping bug when mousing over rows in the tbody */

top: expression( this.parentNode.parentNode.parentNode.scrollTop + 'px' );

}

 

/* Fixed Header */

.FixedTableHead table thead tr td {

border-bottom:1px solid #000000;

background-color:white;

}

</style>

 

</head>

 

<body>

 

Lock Table Headings<br />

<?php

 

echo"<div class="FixedTableHead">";

echo"<table cellspacing=0 style="height:100px;">";

echo" <thead>";

echo" <tr><td>ID</td></tr>";

echo" </thead>";

$query =  "select id from master where period='09P3'";

$result = mysql_query($query) or die(mysql_error());

 

while($row = mysql_fetch_array($result)){

echo" <tbody>

<tr><td > {$row[id]}</td></tr>

 

</tbody>";

}

echo" </table>";

echo"</div>";

?>

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/172134-table-locking-code/
Share on other sites

Please use


tags.

 

You have to learn about string formatting and interpolation.  You're using double quotes for your string and attributes.  The attributes should be using single quotes.

 

 {$row[id]}

 

In the line above, you're using curly braces for no reason.  Associative arrays are supposed to have single quotes around the keys and surrounding it with curly braces allows you to do that.

Link to comment
https://forums.phpfreaks.com/topic/172134-table-locking-code/#findComment-907589
Share on other sites

Please use code tags next time...

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php include ("login.php");?>

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Lock Table Head</title>

<style type='text/css'>

/* DIV container around table to constrict the height for IE (IE ignores the tbody height style) */
div.FixedTableHead {
   overflow-y:auto;
   
   /* this fixes IE so container width is same as table width */
   width: expression( (this.childNodes[0].clientWidth + 24) + 'px' );
   
   /* This fixes IE so the container height is table height plus the height of the header */
   height: expression( (parseInt(this.childNodes[0].style.height) + this.childNodes[0].childNodes[1].offsetTop + 1) +'px' );
}

/* Scrollable Content */
.FixedTableHead table tbody {
   height:100%;
   overflow-x:hidden;
   overflow-y:auto;
}

.FixedTableHead table tbody tr {
   height: auto;
   white-space: nowrap;
}

/* Prevent Mozilla scrollbar from hiding right-most cell content */
.FixedTableHead table tbody tr td:last-child {
   padding-right: 20px;
}

/* Fixed Header */
/* In WinIE any element with a position property set to relative and is a child of       */
/* an element that has an overflow property set, the relative value translates into fixed.    */
/* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */
.FixedTableHead table thead tr {
   position: relative;
   height: auto;
   /* this fixes IE header jumping bug when mousing over rows in the tbody */
   top: expression( this.parentNode.parentNode.parentNode.scrollTop + 'px' );
}

/* Fixed Header */
.FixedTableHead table thead tr td {
   border-bottom:1px solid #000000;
   background-color:white;
}
</style>

</head>

<body>

Lock Table Headings<br />


<div class='FixedTableHead'>
<table cellspacing=0 style='height:100px;'>
<thead>
<tr><td>ID</td></tr>
</thead>
<?php
      $query =  "select id from master where period='09P3'";
      $result = mysql_query($query) or die(mysql_error());
   
while($row = mysql_fetch_array($result)){
   echo"   <tbody><tr><td> {$row['id']}</td></tr>
   
      </tbody>";
   }
echo"   </table>";
echo"</div>";
?>

</body>
</html>

 

The errors were been caused by your extra quotes on your attributes. I just moved them out of the php section for now. I also added single quotes to your array keys...

 

Doh somoene beat me to it but im posting this anyway...

Link to comment
https://forums.phpfreaks.com/topic/172134-table-locking-code/#findComment-907591
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.