473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to handle json data in zend while using flexigrid

pradeepjain
563 512MB
i have a page post2.php which prints the json array like

Expand|Select|Wrap|Line Numbers
  1. {
  2. page: 1,
  3. total: 239,
  4. rows: [
  5. {id:'239',cell:['239','ZW','ZIMBABWE','Zimbabwe','ZWE','716']},
  6. {id:'238',cell:['238','ZM','ZAMBIA','Zambia','ZMB','894']},
  7. {id:'237',cell:['237','YE','YEMEN','Yemen','YEM','887']},
  8. {id:'236',cell:['236','EH','WESTERN SAHARA','Western Sahara','ESH','732']},
  9. {id:'235',cell:['235','WF','WALLIS AND FUTUNA','Wallis and Futuna','WLF','876']},
  10. {id:'234',cell:['234','VI','VIRGIN ISLANDS, U.S.','Virgin Islands, U.s.','VIR','850']},
  11. {id:'233',cell:['233','VG','VIRGIN ISLANDS, BRITISH','Virgin Islands, British','VGB','92']},
  12. {id:'232',cell:['232','VN','VIET NAM','Viet Nam','VNM','704']},
  13. {id:'231',cell:['231','VE','VENEZUELA','Venezuela','VEN','862']},
  14. {id:'230',cell:['230','VU','VANUATU','Vanuatu','VUT','548']}]
  15. }
and here is the post2.php code

Expand|Select|Wrap|Line Numbers
  1. <?
  2. error_reporting(1);
  3. function runSQL($rsql) {
  4.         $hostname = "localhost";
  5.         $username = "root";
  6.         $password = "root";
  7.         $dbname   = "hms1";
  8.         $connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");
  9.         $db = mysql_select_db($dbname);
  10.         $result = mysql_query($rsql) or die ('test');
  11.         return $result;
  12.         mysql_close($connect);
  13. }
  14.  
  15. function countRec($fname,$tname,$where) {
  16. $sql = "SELECT count($fname) FROM $tname $where";
  17. $result = runSQL($sql);
  18. while ($row = mysql_fetch_array($result)) {
  19. return $row[0];
  20. }
  21. }
  22. $page = $_POST['page'];
  23. $rp = $_POST['rp'];
  24. $sortname = $_POST['sortname'];
  25. $sortorder = $_POST['sortorder'];
  26.  
  27. if (!$sortname) $sortname = 'pa_name';
  28. if (!$sortorder) $sortorder = 'desc';
  29.                 if($_POST['query']!=''){
  30.                         $where = "WHERE `".$_POST['qtype']."` LIKE '%".$_POST['query']."%' ";
  31.                 } else {
  32.                         $where ='';
  33.                 }
  34.                 if($_POST['letter_pressed']!=''){
  35.                         $where = "WHERE `".$_POST['qtype']."` LIKE '".$_POST['letter_pressed']."%' ";
  36.                 }
  37.                 if($_POST['letter_pressed']=='#'){
  38.                         $where = "WHERE `".$_POST['qtype']."` REGEXP '[[:digit:]]' ";
  39.                 }
  40. $sort = "ORDER BY $sortname $sortorder";
  41.  
  42. if (!$page) $page = 1;
  43. if (!$rp) $rp = 10;
  44.  
  45. $start = (($page-1) * $rp);
  46.  
  47. $limit = "LIMIT $start, $rp";
  48. $sql = "SELECT pa_id,pa_name,pa_pd_patient_id,pa_name FROM patient_appointment $where $sort $limit";
  49. $result = runSQL($sql);
  50.  
  51. $total = countRec('pa_id','patient_appointment',$where);
  52.  
  53. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
  54. header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
  55. header("Cache-Control: no-cache, must-revalidate" );
  56. header("Pragma: no-cache" );
  57. header("Content-type: text/x-json");
  58. $json = "";
  59. $json .= "{\n";
  60. $json .= "page: $page,\n";
  61. $json .= "total: $total,\n";
  62. $json .= "rows: [";
  63. $rc = false;
  64. while ($row = mysql_fetch_array($result)) {
  65. if ($rc) $json .= ",";
  66. $json .= "\n{";
  67. /*$json .= "cell:['".$row['pa_name']."'";
  68. $json .= ",'".addslashes($row['time'])."'";
  69. $json .= ",'".addslashes($row['pa_um_id'])."'";
  70. $json .= ",'".addslashes($row['pa_pd_patient_id'])."']";*/
  71. $json .= "id:'".$row['pa_id']."',";
  72. $json .= "cell:['".$row['pa_id']."','".$row['pa_name']."'";
  73. $json .= ",'".addslashes($row['pa_pd_patient_id'])."']";
  74.  
  75. $json .= "}";
  76. $rc = true;
  77. }
  78. $json .= "]\n";
  79. $json .= "}";
  80. echo $json;
  81. ?>
  82.  
and in zend views i am trying to use flexigrid like this

Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function(){
  2.  
  3.         $("#flex1").flexigrid
  4.                         (
  5.                         {
  6.                         url: '/public/**post2.ph**p',
  7.                         dataType: 'json',
  8.                         colModel : [
  9.                                 {display: 'ID', name : 'id', width : 40, sortable : true, align: 'center'},
  10.                                 {display: 'ISO', name : 'iso', width : 40, sortable : true, align: 'center'},
  11.                                 {display: 'Name', name : 'name', width : 180, sortable : true, align: 'left'},
  12.                                 {display: 'Printable Name', name : 'printable_name', width : 120, sortable : true, align: 'left'},
  13.                                 {display: 'ISO3', name : 'iso3', width : 130, sortable : true, align: 'left', hide: true},
  14.                                 {display: 'Number Code', name : 'numcode', width : 80, sortable : true, align: 'right'}
  15.                                 ],
  16.                         buttons : [
  17.                                 {name: 'Add', bclass: 'add', onpress : test},
  18.                                 {name: 'Delete', bclass: 'delete', onpress : test},
  19.                                 {separator: true},
  20.                                 {name: 'A', onpress: sortAlpha},
  21.                                 ],
  22.                         searchitems : [
  23.                                 {display: 'ISO', name : 'iso'},
  24.                                 {display: 'Name', name : 'name', isdefault: true}
  25.                                 ],
  26.                         sortname: "id"
  27.                         sortorder: "asc",
  28.                         usepager: true,
  29.                         title: 'Countries',
  30.                         useRp: true,
  31.                         rp: 10,
  32.                         showTableToggleBtn: true,
  33.                         width: 700,
  34.                         height: 255
  35.                         }
  36.                         );  
  37.  
  38. });
  39.  
  40.  
this prints the flexigrid layout well.. but never gets the data.it keeps telling processing. is there some problem in the json array or in the flexigrid calling... or in zend with json.

i tried out like this also in the views page and the 'hai' is also not getting alerted .

Expand|Select|Wrap|Line Numbers
  1. $.post("/public/server_processing1.php",{},function(data){
  2. alert('hai');
  3. alert(data);
  4. }, "json");
  5.  

is there a way to handle json data in zend .
May 19 '10 #1
2 4575
Markus
6,050 Expert 4TB
I imagine you should take this up with the developer of the JS library - this isn't a PHP issue.
May 19 '10 #2
pradeepjain
563 512MB
@Markus
i run the code outside zend . it works well. but inside zend it does not.so asked here
May 20 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Geoffrey | last post by:
I am working on a file conversion project that reads data from a one file format, reformats in and writes in out to another. The data is records of informations - names address, account...
0
by: Magic1812 | last post by:
Magic Software invites you to join us this coming Tuesday (January 27th, 2004) at 12:00 EDT / 17:00 GMT for a FREE live Webinar: Title: Data Integrity Using eDeveloper Date: January 27, 2004...
2
by: Gary42103 | last post by:
Hi I need Perl Script to do Data Parsing using existing data files. I have my existing data files in the following directory: Directory Name: workfs/ams Data File Names: 20070504.dat,...
5
by: orabalu | last post by:
Hi Guys, Can you give me some examples for Incremental load in PL/SQL for Datawarehouse projects. Regards, Balu
3
by: xhe | last post by:
I found Jason is a very handy data format for client/server communication. But I just met a problem as follows: I want to read the data replied from server in Jason format, the reply is like...
3
nathj
by: nathj | last post by:
Hi everyone, I am currently working on a project where data is being passed from the cilent side to the server side quite a lot. I thought that AJAX and JSON would be perfect for this. I have...
5
by: DR | last post by:
Why is its substantialy slower to load 50GB of gzipped file (20GB gzipped file) then loading 50GB unzipped data? im using System.IO.Compression.GZipStream and its not maxing out the cpu while...
9
ssnaik84
by: ssnaik84 | last post by:
Hello, I am trying to integrate FlexBox It uses JSON data to populate listbox items. It internally calls a server side page with AJAX, and reads the JSON results from that page. for example,...
7
by: elvehjem | last post by:
Hi, I'm trying to learn JavaScript. I'm missing something that has to do w/ reading stuff from (what I hope is) a JSON data structure. This function: function myFunction(){ ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.