Jump to content

show/hide columns in a table script


bloodeye

Recommended Posts

i'm trying to make a documentary indexing website for docus from usenet ,non profit project

 

i managed to make a table like this one http://www.frequency-decoder.com/demo/table-sort-revisited/

 

but got stuck on the next step , which is creating checkboxes for the columns , to be able to hide/show them , cause i want a column for everything like bitrate,resolutionj,rating,budget etc etc , and this way you could hide the columns you're not interested atm so that the page doesnt get to wide

 

 

this is my code :

 

<?php require_once('Connections/connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
mysql_select_db($database_connection, $connection);
$query_Recordset1 = "SELECT Title, Category, Series, Episode, `Year`, Resolution, `Video Bitrate`, `Video Codec` FROM documentaries";
$Recordset1 = mysql_query($query_Recordset1, $connection) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<html>
<head>
    
    <script type="text/javascript" src="tablesort.js"></script>
<script type="text/javascript">function hideShow("Title", "checkboxTitle"){
    if(document.getElementById("checkboxTitle").checked == true){ show("Title");}
    else{ hide("Title");}
    }

    function hide("Title"){
    document.getElementById("Recordset1").hideColumn(parseInt("Title"));
    document.getElementById("Recordset1").refreshView();
    };
    function show("Title"){
    document.getElementById("Recordset1").showColumn(parseInt("Title"));
    document.getElementById("Recordset1").refreshView();
    }; 
    var table = document.getElementByID("Recordset1");

table.rows[index]


    
    </script>
<title>Main Table</title>
    
    <link href="StyleSheets.css" rel="stylesheet" type="text/css">
</head>

<body>
    <?php include("includes/header.php"); ?>
      <div align="center"><br>
        <span class="tip"></br>
        <br></br>
        Hold down shift to sort by multiple columns </span><br></br>
        <script fdTableSort.jsWrapper("Recordset1"); ></script>
      </div>
      <input type="checkbox" name="checkboxTitle" id="checkboxTitle" onclick ="hideShow('Title', 'checkboxTitle')">
      <table id="Recordset1" name="Recordset1">
        <tr>
          <th class="sortable" >Title</th>
          <th class="sortable" >Category</th>
          <th class="sortable" >Series</th>
          <th class="sortable" >Episode</th>
          <th class="sortable" >Year</th>
          <th class="sortable" >Resolution</th>
          <th class="sortable" >Video Bitrate</th>
          <th class="sortable" >Video Codec</th>
       </tr>
        <?php do { ?>
          <tr > 
            <td><?php echo $row_Recordset1['Title']; ?></td>
            <td><?php echo $row_Recordset1['Category']; ?></td>
            <td><?php echo $row_Recordset1['Series']; ?></td>
            <td><?php echo $row_Recordset1['Episode']; ?></td>
            <td><?php echo $row_Recordset1['Year']; ?></td>
            <td><?php echo $row_Recordset1['Resolution']; ?></td>
            <td><?php echo $row_Recordset1['Video Bitrate']; ?></td>
            <td><?php echo $row_Recordset1['Video Codec']; ?></td>
          </tr>
          <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
      </table>
<?php include("includes/footer.php"); ?>
</body>
     
</html>
<?php
mysql_free_result($Recordset1);
?>

 

a few people tried to help but said they needed all the files of the site , and that would require to install it on wamp

 

i've atached the whole thing in case someone can help

 

i've also tried this too http://www.fiendish.demon.co.uk/html/javascript/hidetablecols.html but wasnt able to make that work either

 

[attachment deleted by admin]

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.