i have a page post2.php which prints the json array like - {
-
page: 1,
-
total: 239,
-
rows: [
-
{id:'239',cell:['239','ZW','ZIMBABWE','Zimbabwe','ZWE','716']},
-
{id:'238',cell:['238','ZM','ZAMBIA','Zambia','ZMB','894']},
-
{id:'237',cell:['237','YE','YEMEN','Yemen','YEM','887']},
-
{id:'236',cell:['236','EH','WESTERN SAHARA','Western Sahara','ESH','732']},
-
{id:'235',cell:['235','WF','WALLIS AND FUTUNA','Wallis and Futuna','WLF','876']},
-
{id:'234',cell:['234','VI','VIRGIN ISLANDS, U.S.','Virgin Islands, U.s.','VIR','850']},
-
{id:'233',cell:['233','VG','VIRGIN ISLANDS, BRITISH','Virgin Islands, British','VGB','92']},
-
{id:'232',cell:['232','VN','VIET NAM','Viet Nam','VNM','704']},
-
{id:'231',cell:['231','VE','VENEZUELA','Venezuela','VEN','862']},
-
{id:'230',cell:['230','VU','VANUATU','Vanuatu','VUT','548']}]
-
}
and here is the post2.php code - <?
-
error_reporting(1);
-
function runSQL($rsql) {
-
$hostname = "localhost";
-
$username = "root";
-
$password = "root";
-
$dbname = "hms1";
-
$connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");
-
$db = mysql_select_db($dbname);
-
$result = mysql_query($rsql) or die ('test');
-
return $result;
-
mysql_close($connect);
-
}
-
-
function countRec($fname,$tname,$where) {
-
$sql = "SELECT count($fname) FROM $tname $where";
-
$result = runSQL($sql);
-
while ($row = mysql_fetch_array($result)) {
-
return $row[0];
-
}
-
}
-
$page = $_POST['page'];
-
$rp = $_POST['rp'];
-
$sortname = $_POST['sortname'];
-
$sortorder = $_POST['sortorder'];
-
-
if (!$sortname) $sortname = 'pa_name';
-
if (!$sortorder) $sortorder = 'desc';
-
if($_POST['query']!=''){
-
$where = "WHERE `".$_POST['qtype']."` LIKE '%".$_POST['query']."%' ";
-
} else {
-
$where ='';
-
}
-
if($_POST['letter_pressed']!=''){
-
$where = "WHERE `".$_POST['qtype']."` LIKE '".$_POST['letter_pressed']."%' ";
-
}
-
if($_POST['letter_pressed']=='#'){
-
$where = "WHERE `".$_POST['qtype']."` REGEXP '[[:digit:]]' ";
-
}
-
$sort = "ORDER BY $sortname $sortorder";
-
-
if (!$page) $page = 1;
-
if (!$rp) $rp = 10;
-
-
$start = (($page-1) * $rp);
-
-
$limit = "LIMIT $start, $rp";
-
$sql = "SELECT pa_id,pa_name,pa_pd_patient_id,pa_name FROM patient_appointment $where $sort $limit";
-
$result = runSQL($sql);
-
-
$total = countRec('pa_id','patient_appointment',$where);
-
-
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
-
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
-
header("Cache-Control: no-cache, must-revalidate" );
-
header("Pragma: no-cache" );
-
header("Content-type: text/x-json");
-
$json = "";
-
$json .= "{\n";
-
$json .= "page: $page,\n";
-
$json .= "total: $total,\n";
-
$json .= "rows: [";
-
$rc = false;
-
while ($row = mysql_fetch_array($result)) {
-
if ($rc) $json .= ",";
-
$json .= "\n{";
-
/*$json .= "cell:['".$row['pa_name']."'";
-
$json .= ",'".addslashes($row['time'])."'";
-
$json .= ",'".addslashes($row['pa_um_id'])."'";
-
$json .= ",'".addslashes($row['pa_pd_patient_id'])."']";*/
-
$json .= "id:'".$row['pa_id']."',";
-
$json .= "cell:['".$row['pa_id']."','".$row['pa_name']."'";
-
$json .= ",'".addslashes($row['pa_pd_patient_id'])."']";
-
-
$json .= "}";
-
$rc = true;
-
}
-
$json .= "]\n";
-
$json .= "}";
-
echo $json;
-
?>
-
and in zend views i am trying to use flexigrid like this - $(document).ready(function(){
-
-
$("#flex1").flexigrid
-
(
-
{
-
url: '/public/**post2.ph**p',
-
dataType: 'json',
-
colModel : [
-
{display: 'ID', name : 'id', width : 40, sortable : true, align: 'center'},
-
{display: 'ISO', name : 'iso', width : 40, sortable : true, align: 'center'},
-
{display: 'Name', name : 'name', width : 180, sortable : true, align: 'left'},
-
{display: 'Printable Name', name : 'printable_name', width : 120, sortable : true, align: 'left'},
-
{display: 'ISO3', name : 'iso3', width : 130, sortable : true, align: 'left', hide: true},
-
{display: 'Number Code', name : 'numcode', width : 80, sortable : true, align: 'right'}
-
],
-
buttons : [
-
{name: 'Add', bclass: 'add', onpress : test},
-
{name: 'Delete', bclass: 'delete', onpress : test},
-
{separator: true},
-
{name: 'A', onpress: sortAlpha},
-
],
-
searchitems : [
-
{display: 'ISO', name : 'iso'},
-
{display: 'Name', name : 'name', isdefault: true}
-
],
-
sortname: "id"
-
sortorder: "asc",
-
usepager: true,
-
title: 'Countries',
-
useRp: true,
-
rp: 10,
-
showTableToggleBtn: true,
-
width: 700,
-
height: 255
-
}
-
);
-
-
});
-
-
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 . - $.post("/public/server_processing1.php",{},function(data){
-
alert('hai');
-
alert(data);
-
}, "json");
-
is there a way to handle json data in zend .
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.
@Markus
i run the code outside zend . it works well. but inside zend it does not.so asked here
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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
|
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
|
by: orabalu |
last post by:
Hi Guys,
Can you give me some examples for Incremental load in PL/SQL for Datawarehouse projects.
Regards,
Balu
|
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
| |
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 = '{';
|
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!
|
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.
|
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 = "";
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |