Código PHP:
function grid_scroll_bar($titulo,$consulta,$div,$campos,$campos_hint,$alto,$ancho,$hostname_obras,$database_obras,$username_obras,$password_obras,$columnas) {
$obras = mysql_pconnect($hostname_obras, $username_obras, $password_obras) or trigger_error(mysql_error(),E_USER_ERROR); //Se usan rutas persistentes
mysql_select_db($database_obras, $obras);
$query_gridsql = sprintf($consulta);
$gridsql = mysql_query($query_gridsql, $obras) or die(mysql_error());
$row_gridsql = mysql_fetch_assoc($gridsql);
$totalRows_gridsql = mysql_num_rows($gridsql);
$campo[] = explode(",",$campos);
$total_campos = count($campo);
$grid = "<script type='text/javascript'>";
$grid .= "Ext.onReady(function(){";
$grid .= "var myData = [";
if ($campos_hint!="") {
$query_hintsql = "WHERE ".$campo[0]." LIKE '".$row_gridsql[$id_campo]."'";
mysql_select_db($database_obras, $obras);
$query_hintsql = sprintf($consulta);
$hintsql = mysql_query($query_hintsql, $obras) or die(mysql_error());
$row_hintsql = mysql_fetch_assoc($hintsql);
}
do {
$grid .= "[";
$arreglo = array();
for ($i = 0; $i < $total_campos; $i++) {
$id_campo = $campo[$i];
$arreglo[] = $row_gridsql[$id_campo]; //<-- Lina 264 en mi codigo
}
if (count($arreglo) > 0) {
$arreglo1 = implode(",",$arreglo);
$grid .= $arreglo1;
}
$grid .= "],";
} while($row_gridsql = mysql_fetch_assoc($gridsql));
$grid .= "];";
// create the data store
$grid .= "var store = new Ext.data.Store({";
$grid .= "proxy: new Ext.ux.data.PagingMemoryProxy(myData),";
$grid .= "remoteSort:true,";
$grid .= "sortInfo: {field:'".$campo[0]."', direction:'DESC'},";
$grid .= "reader: new Ext.data.ArrayReader({";
$grid .= "fields: [";
//Empezar ciclo
for ($j = 0; $j < $total_campos; $j++) {
if ($j<$total_campos) {
$grid .= "{name:'".$row_gridsql[$j]."'},";
}
if ($j==$total_campos) {
$grid .= "{name:'".$row_gridsql[$j]."'}";
}
}
//Finalizar ciclo
$grid .= "]";
$grid .= "})";
$grid .= "})";
// create the Grid
$grid .= "var grid = new Ext.grid.GridPanel({";
$grid .= "store: store,";
$grid .= " columns: [";
//Empezar el ciclo
for ($k = 0; $k < $total_campos; $k++) {
if ($k==0) {
$grid .= " {id: '".$campo[$k]."', sortable: true, dataIndex: '".$campo[$k]."'}, ";
}
if ($k<$total_campos) {
$grid .= "{header: '".$campo[$k]."', sortable: true, dataIndex: '".$campo[$k]."'},";
}
if ($k==$total_campos) {
$grid .= "{header: '".$campo[$k]."', sortable: true, dataIndex: '".$campo[$k]."'}";
}
}
//Finalizar ciclo
$grid .= " ],";
$grid .= " stripeRows: true,";
$grid .= " autoExpandColumn: '".$campo[0]."',";
$grid .= " height:".$alto.",";
$grid .= " width:".$ancho.",";
$grid .= " frame:true,";
$grid .= " title:'".$titulo."',";
$grid .= " plugins: new Ext.ux.PanelResizer({";
$grid .= " minHeight: 100";
$grid .= " }),";
$grid .= "bbar: new Ext.PagingToolbar({";
$grid .= "pageSize: 10,";
$grid .= "store: store,";
$grid .= "displayInfo: true,";
$grid .= "plugins: new Ext.ux.ProgressBarPager()";
$grid .= " })";
$grid .= "});";
$grid .= "grid.render('".$div."');";
$grid .= "store.load({params:{start:0, limit:".$columnas."}})";
$grid .= "});";
$grid .= "</script>";
return $grid;
}
Warning: Illegal offset type in D:\wamp\www\gobernacion2\Connections\obras.php on line 264
Warning: Illegal offset type in D:\wamp\www\gobernacion2\Connections\obras.php on line 264