PHP Classes

Passing Values

Recommend this page to a friend!

      DrasticTools  >  All threads  >  Passing Values  >  (Un) Subscribe thread alerts  
Subject:Passing Values
Summary:Passing a value via GET to Grid
Messages:4
Author:Fabio
Date:2011-03-18 14:11:22
Update:2012-01-09 11:32:43
 

  1. Passing Values   Reply   Report abuse  
Picture of Fabio Fabio - 2011-03-18 14:11:23
Is it possible to pass a value via GET to the grid? I have tried to use addparams, but the GET gets cleared. I also tried to add the variable as a session variable, but that is also not working. Any Suggestions?

<code>
<?php
$INC_DIR = $_SERVER["DOCUMENT_ROOT"]. "/lib";
define("PATHDRASTICTOOLS", "$INC_DIR/dt/");

session_start();
if (isset($_GET[partno])) {
$_SESSION[partno] = $_GET[partno];
}

$server="localhost";
$user="xxx";
$pw="xxx";
$db="xxx";
$table="material";

$partno = $_SESSION[partno];

include(PATHDRASTICTOOLS."drasticSrcMySQL.class.php");
class mysrc extends drasticSrcMySQL {
protected function select(){
$res = mysql_query("SELECT * FROM $this->table WHERE partno = '$partno'" . $this->orderbystr, $this->conn) or die(mysql_error());
return ($res);
}
protected function add(){
mysql_query("INSERT INTO $this->table (partno) VALUES('$partno')", $this->conn) or die(mysql_error());
if (mysql_affected_rows($this->conn) == 1) return(true); else return(false);
}
}
$options = array(
"add_allowed" => true,
"delete_allowed" => true,
"editablecols" => array("description", "price", "qty"),
);
$src = new mysrc($server, $user, $pw, $db, $table, $options);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="/lib/dt/css/grid_default.css"/>
<title>Quote Sheet</title>
</head><body>
<script type="text/javascript" src="/lib/dt/js/mootools-1.2-core.js"></script>
<script type="text/javascript" src="/lib/dt/js/mootools-1.2-more.js"></script>
<script type="text/javascript" src="/lib/dt/js/drasticGrid.js"></script>
<? echo $partno ?>
<div id="grid1"></div>
<script type="text/javascript">
var thegrid = new drasticGrid('grid1', {
pathimg:"/lib/dt/img/",
sliderposition: "left",
pagelength: "5",
addparams: "&partno=<?php echo $partno ?>",
columns: [
{name: 'description'},
{name: 'price'},
{name: 'qty'}
]
});
</script>

</body></html>
</code>

  2. Re: Passing Values   Reply   Report abuse  
Picture of Fabio Fabio - 2011-03-18 19:14:59 - In reply to message 1 from Fabio
I got this working. I missed the variable not being passed to the function. Now however I need to be able to get two grids on the same page filtered by the same variable. Is this possible?

  3. Re: Passing Values   Reply   Report abuse  
Picture of dd dd - 2011-03-18 21:14:56 - In reply to message 2 from Fabio
Hi Fabio,

Glad you got it working.
Two instances of drasticgrid should be no problem, see example
localhost/DrasticData/DrasticTools/ ...
Two instances filtered by the same variable should be possible too, however you may have to do a refresh of the grids if it changes. If so, you can use the refresh function in the drasticgrid.js

regards, dd

  4. Re: Passing Values   Reply   Report abuse  
Picture of Jari Kinnunen Jari Kinnunen - 2012-01-09 11:32:43 - In reply to message 2 from Fabio
Ciao Fabio!

I had the same case, it didn't work for me either. You described that the variable did not pass to the function. What made it work, can't see the solution to that?

Best regards
Jari