Bom, pra começar não sou programador, sou designer mas como esta sem programador la no meu trampo botaram o pepino no meu rabo, enfim, trabalho em uma empresa de cameras digitais e querem q eu faça um sistema de busca para a assistencia tecnica, que quando a pessoa entre com login e senha, pegue o cnpj e já filtre os dados pra aparecer só as cameras que tem praquele cnpj (q a pessoa deixou na assistencia), bem pra começar tenho q fazer essa busca funcionar, como não sabia por onde começar pesquise na net, achei uns modelos de datagrid e fui modificando pra ficar como eles queriam, consegui e localmente ele tava mostrando todos os dados mas quando joguei pro servidor ele não traz nada, o link é esse: http://www.bma.com.br/suporte/assistec/soaurce/ o codigo do listar_usuarios.php é esse <?php
$user='root';
$pw='';
$db='bma';
$table='assis_tec';
$connection = mysql_connect("localhost", $user, $pw) or
die("Could not connect: " . mysql_error());
mysql_select_db($db) or die("Could not select database");
$task = ($_POST['task']) ? ($_POST['task']) : null;
switch($task){
case "readAssistec":
showData('assis_tec');
break;
}
function showData($table)
{
$start = (integer) (isset($_POST['start']) ? $_POST['start'] : $_GET['start']);
$end = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_GET['limit']);
$sql_count = "SELECT * FROM $table";
$sql = $sql_count . ' LIMIT ' . $start . ', '. $end;
$result_count = mysql_query($sql_count);
$rows = mysql_num_rows($result_count);
$result = mysql_query($sql);
while($rec = mysql_fetch_array($result, MYSQL_ASSOC)){
$arr[] = $rec;
};
if (version_compare(PHP_VERSION,"5.2","<"))
{
require_once("./JSON.php");
$json = new Services_JSON();
$data=$json->encode($arr);
} else
{
$data = json_encode($arr);
}
$cb = isset($_GET['callback']) ? $_GET['callback'] : '';
echo $cb . '({"total":"' . $rows . '","results":' . $data . '})';
}
?>
sim, eu mudei o usuario e a senha quando joguei pro servidor
o codigo do javascript q chama esse listar_usuarios.php é esse
Ext.onReady(function(){
Ext.ux.menu.RangeMenu.prototype.icons = {
gt: 'img/greater_then.png',
lt: 'img/less_then.png',
eq: 'img/equals.png'
};
Ext.ux.grid.filter.StringFilter.prototype.icon = 'img/find.png';
var myRecordObj = Ext.data.Record.create([
{name:'razao_social'},
{name:'numserie'},
{name:'modelo'},
{name:'nfiscal_e'},
{name:'cnpj'},
{name:'numos'},
{name:'numosaut'},
{name:'nfiscal_s'},
{name:'correio'}
]);
ds = new Ext.data.GroupingStore({
proxy: new Ext.data.HttpProxy({
url:'listar_usuarios.php',
method: 'POST'
}),
baseParams:{task: "readAssistec"},
reader: new Ext.data.JsonReader({
id: 'id_usuario',
totalProperty: 'total',
root: 'results'
},
myRecordObj),
sortInfo: {field: 'razao_social', direction: 'ASC'},
remoteSort: true
});
var filters = new Ext.ux.grid.GridFilters({filters:[
{type: 'string', dataIndex: 'razao_social'},
{type: 'string', dataIndex: 'numserie'},
{type: 'string', dataIndex: 'modelo'},
{type: 'string', dataIndex: 'nfiscal_e'},
{type: 'string', dataIndex: 'cnpj'},
{type: 'string', dataIndex: 'numos'},
{type: 'string', dataIndex: 'numosaut'},
{type: 'string', dataIndex: 'nfiscal_s'},
{type: 'string', dataIndex: 'correio'}
]});
var cm = new Ext.grid.ColumnModel([{
dataIndex: 'razao_social',
header: 'Razao',
width: 250
}, {
dataIndex: 'numserie',
header: 'Numero de Serie',
width: 95
}, {
dataIndex: 'modelo',
header: 'Modelo',
width: 95
}, {
dataIndex: 'nfiscale',
header: 'Nota Fiscal E',
width: 85
}, {
dataIndex: 'cnpj',
header: 'CNPJ',
width: 115
}, {
dataIndex: 'numos',
header: 'Numero O.S.',
width: 85
}, {
dataIndex: 'numosaut',
header: 'Numero O.S. Autorizada',
width: 130
}, {
dataIndex: 'nfiscal_s',
header: 'Nota Fiscal S',
width: 73
}, {
dataIndex: 'correio',
header: 'Correio',
width: 53
}]);
cm.defaultSortable = true;
var grid = new Ext.grid.GridPanel({
id: 'example',
ds: ds,
cm: cm,
enableColLock: false,
loadMask: true,
view: new Ext.grid.GroupingView(),
plugins: filters,
height:560,
width:985,
el: 'grid-example',
bbar: new Ext.PagingToolbar({
store: ds,
pageSize: 24
})
});
grid.render();
ds.load({params:{start: 0, limit: 24}});
}); não sei o que pode estar errado, se alguém puder me ajudar eu agradeceria muito muito mesmo, pois preciso fazer isso de qualquer forma