Jump to content

Recommended Posts

Hello I'm trying to use a PEAR table but I am getting this error.

 

<?php
  // Include the DB access credentials
  require '../dbcred.php';
  // Include the PEAR Structures_DataGrid class
  require 'Structures/DataGrid.php';

  error_reporting(E_ALL);
  
  // Custom Output Callback Functions
  function ge($data)
  {
    $link = $data['record']['Product_URL'];
return $link;
  }

  
  $datagrid = new Structures_DataGrid(10);
  
  // Add Custom Columns
  $name = new Structures_DataGrid_Column("Product_URL", "Product_URL", 
      "Product_URL", null, null, "ge()");
  $datagrid->addColumn($name);
  

  
  // Add Default Sort
  $datagrid->setDefaultSort(array('Product_URL' => 'ASC'));
  
  $options = array('dsn' => "mysql://$user:$password@$db_host/$db_name");
  $sql = "SELECT * FROM csv";
      
   // Bind the Query to our Datagrid
  $bind = $datagrid->bind($sql, $options);
  // Test for Errors
  if (PEAR::isError($bind))
  {
    error_log('DataGrid Error: '. $bind->getMessage());
    $gridsource = '';
  }
  else
  {
    $renderer_options = array(
        'sortIconASC' => '<img src="images/up.gif" />',
        'sortIconDESC' => '<img src="images/down.gif" />',
        'headerAttributes' => array('bgcolor' => '#E3E3E3'),
        'evenRowAttributes' => array('bgcolor' => '#A6A6A6'),
    );
    $datagrid->setRendererOptions($renderer_options);
    
    $renderer = $datagrid->getRenderer();
$renderer->setTableAttribute('width', '100%');
    $renderer->setTableAttribute('cellspacing', 0);
    $renderer->setTableAttribute('cellpadding', 5);
    $renderer->setTableAttribute('border', 1);
    
    // Render the table, be sure to check for errors 
    $gridbody = $datagrid->getOutput();
    if (PEAR::isError($gridbody))
    {
      error_log('DataGrid render error: ' . $gridbody->getMessage());
      $gridbody = '';
    }
    // Finally, render the pager, again checking for errors
    $gridpager = $datagrid->getOutput(DATAGRID_RENDER_PAGER);
    if (PEAR::isError($gridpager))
    {
      error_log('DataGrid render error: ' . $gridpager->getMessage());
      $gridpager = '';
    }
    $gridsource = $gridbody . $gridpager;
  }
?>
<!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>PEAR::Structures_DataGrid, Customized!</title>
    <meta http-equiv="Content-type"
        content="text/html; charset=iso-8859-1" />
    <style type="text/css">
      body {
        font-family: Tahoma, Arial, Helvetica, sans-serif;
        font-size: 11px;
      }
      h1 {
        font-size: 1.2em;
        color: navy
      }
      img {
        border: none;
      }
    </style>
  </head>
  <body>
    <h1>DataFeed Manager</h1>

<?php echo $gridsource; 
 ?>
  </body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/132561-pear-error/
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.