PDA

View Full Version : PHP source code of forums-remote.php



mazdov
14 Mar 2010, 12:54 AM
Hello, trying to build the tree (like in forum.js example) from my own php, but there is nothing...
Guess there is some parameters from server i need to send together with json tree structure.
Can anyone send me the forums-remote.php to understand the server side actions?
Please help!!!
Thanks in advance

t0ad999
29 Jan 2011, 12:25 AM
I'm looking for the actual source code from http://www.sencha.com/forum/topics-browse-remote.php minus all the privy data.

I would like to use the same source to connect to my own database and populate my own news information using the functions provided with the example enclosed with the extJS package. It would be easier for me to see the source so I can better understand how to communicate with PHP.... thanks!

t0ad999
1 Feb 2011, 7:10 AM
the following code has all the information needed to utilizing the paging functionality and json conversion from the example. But for my own site. Hope it helps someone else.


if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");

$result = mysql_query("SELECT COUNT(*) AS count FROM {$table} ");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];


// Query DB for Category parent information
$res = mysql_query("SELECT * FROM {$table} order by {$sort} {$dir} LIMIT {$start} , {$limit} ");

// iterate over every row
while ($row = mysql_fetch_assoc($res)) {
// for every field in the result..
for ($i=0; $i < mysql_num_fields($res); $i++) {
$info = mysql_fetch_field($res, $i);
$type = $info->type;

// cast for real
if ($type == 'real')
$row[$info->name] = doubleval($row[$info->name]);
// cast for int
if ($type == 'int')
$row[$info->name] = intval($row[$info->name]);
}

$rows[] = $row;
}

// JSON-ify all rows together as one big array
echo "{\"totalCount\":\"$count\",\"newscontent\":" . json_encode($rows) . "}";

sll994
2 May 2013, 3:38 AM
I was print_r the data, I noticed the Ext.data.ScriptTagProxy will send the default callback function to PHP. Example,

Array( [_dc] => 1367494131528 [callback] => stcCallback1001)

So, in the forums-remote.php just add the stcCallback1001() function before the json_encoded data like below.

echo 'stcCallback1001({"totalCount":"6679","topics":[{"title":"XTemplate with in EditorGridPanel"}]})';

Let me know, if your side still cannot load the proxy data.


Michael,
http://limcorp.net
E (http://limcorp.net)xtjs Developer