473,671 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to handle json data in zend while using flexigrid

pradeepjain
563 Contributor
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 4586
Markus
6,050 Recognized Expert Expert
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 Contributor
@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
4563
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 number,statistics. The numeric values in the original file are stored in what appears to be a "packed" data format,using a structure that does not use any of the more standard "C" formats, so I can't use the "struct" module. As an example, the number...
0
1896
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 Time: 12:00 PM EST / 17:00 GMT Presenter: Yuval Asheri
2
2426
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, 20070503.dat, 20070502.dat In each of above data files there will be some millions of records. So my job is read those data files and also read first 3 letters of each record in all above data files and write into new data files.For example
5
13894
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
2291
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 this: it is generated automatically by amfphp1.9 from an array. I used Ajax to call a method, and the server code replied an array in the above
3
1351
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 written a small function to generate what I thought was JSON data: function generateJSON(pcIDList) { // set the default return lcReturn = "" ; lcJSONString = '{';
5
2935
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 loading the gzip data! Im using the default buffer of the stream that i open on the 20GB gzipped file and pass it into the GZipStream ctor. then System.IO.Compression.GZipStream takes an hour! when just loading 50GB file of data takes a few minutes!
9
35016
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, $('#flexbox1').flexbox('flexbox-results.aspx'); here, page "flexbox-results.aspx" needs to return JSON result.
7
2399
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(){ outputter = document.getElementById("outputter"); outputter.innerHTML = "";
0
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8911
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8597
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.