Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/10/2011, 22:09
nesmago
 
Fecha de Ingreso: octubre-2011
Mensajes: 14
Antigüedad: 13 años, 5 meses
Puntos: 0
Exclamación java+JSON+javascript

]hola a todos, estoy tratando de hacer una aplicacion web con jsp,
hast ahi todo bien, pero ahora lo que necesito es mostrar con jqgrid una tabla,
desde un JSON que esta en un sertvlet que se llama ActionSetvlet,
he seguido la documentacion de la pagina oficial, pero no logro traducir las siguientes sentencias en php a jsp


Código PHP:
Ver original
  1. $page = $_GET['page']; // get the requested pag
  2. $limit = $_GET['rows']; // get how many rows we want to have into the grid
  3.  $sidx = $_GET['sidx']; // get index row - i.e. user click to sort
  4.  $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1;
  5.  
  6. // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());
  7.  
  8. mysql_select_db($database) or die("Error conecting to db.");
  9.  $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC);
  10. $count = $row['count'];
  11.  
  12. if( $count >0 ) { $total_pages = ceil($count/$limit); }
  13. else { $total_pages = 0; }
  14.  
  15. if ($page > $total_pages) $page=$total_pages;
  16.  $start = $limit*$page - $limit; //do not put $limit*($page - 1)
  17.  $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit";
  18.  $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
  19.  
  20. $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0;
  21.  while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
  22.  $responce->rows[$i]['id']=$row[id]; $responce->rows[$i['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]);
  23.  $i++; }

agradeceria mucho sus aportes