Editor. dependent ('team. content ','../php/countries. php ') for cascading tables; Unable to execut
Editor. dependent ('team. content ','../php/countries. php ') for cascading tables; Unable to execut
Link to test case:
https://editor.datatables.net/examples/advanced/cascadingLists.html
Debugger code (debug.datatables.net):
<?php
// DataTables PHP library
include( "../lib/DataTables.php" );
$values = $_REQUEST['values']['team.continent'];
if (! $values) {
echo json_encode( [] );
return;
}
$countries = $db
->select( 'country', ['id as value', 'name as label'], ['continent' => $_REQUEST['values']['team.continent']] )
->fetchAll();
echo json_encode( [
'options' => [
'team.country' => $countries
]
] );
Error messages shown:
Parse error: syntax error, unexpected '[', expecting ')' in \web\Editorphp\controllers\countries.php on line 8
Description of problem:
https://editor.datatables.net/examples/advanced/cascadingLists.html
Editor. dependent ('team. content ','../../controllers/countries. php ') in; This countries.php cannot be executed in a lower version of PHP (PHP 5.3). How can I modify this code so that it can be executed in PHP 5.3?
Thank you so much
This question has an accepted answers - jump to answer
Answers
When you link to my example as a test case, are you saying the error can be seen on that page? It appears to work okay for me. Or do you mean you are using that same code on your PHP 5.3 server and it is causing issues?
PHP 5.3 is ancient and stop receiving security updates in 2014!
However, the update is fairly straightforward. 5.4 gained the ability to use Javascript like array syntax, so
array()
could be written as[]
.For example, the
echo
could be written as the following in PHP 5.3 code:You need to also update the other array constructors, such as on the
select
line to make it PHP 5.3 compatible.But honestly - upgrade. It's worth it!
Allan
Thank you. I have rewritten it without reporting any errors,But I have another question I want to continue asking
But I have another question I want to continue asking
I have the type2 and type3 fields in the myorder table.
These two fields are linked and their association is based on the myservice table. The myservice table structure is as follows
JS:(Omitted parts)
countries2.php code
staff.php code
When changing TYPE2
Countries2.php output is null :
How can I modify my code?
@allan
If you could link to a page showing the issue that would help be debug it and offer you some help.
I need to know what is being submitted to the server when you change the
type2
field.My guess is that the query condition:
is what is causing the issue.
Allan
The latest key JS code is as follows(Part of the code)
countries2.php*****************
staff.php ************************************(Part of the code)
The TYPE3 output in the table now represents the entire value of the NAME2 field in the SERVICESHOW4 table corresponding to TYPE2, such as Mountaineering, Fashion, Leisure, and Sport. However, what I want is one of the values, such as Sport. I know to use explore and array to separate it, but I don't know where to separate it
I'm finding this really hard to picture I'm afraid. Can you give me a link to the page please?
I'm not clear if the issue is still that
contries2.php
is still returning an empty data array when you select a value, or something else?Allan
是返回空的数组,链接地址是:
http://wh-nxhac0j6fcs69he31w2.my3w.com/temp/gborder.php
That page is giving errors I'm afraid - it looks like jQuery isn't being loaded:
Could you take a look at that, please.
Colin
Sorry,update new link
http://www.oceanshoes.com/temp/gborder.php
@colin @allan
Thanks for the updated link. You don't need to bump your thread just a few hours after posting .
Assuming that
countries2.php
is up to date, then, because the response from the server is simply[]
, then it must be falling into this part:I can see in the request Editor is sending:
So something somewhere is going wrong with the
$_REQUEST
is my guess. Can you add:print_r($_REQUEST);
to your script, just before theecho json_encode(array());
perhaps?Allan
ok
countries2.php
The above is the latest code, and the output print has been added
print_r($_REQUEST);
echo json_encode(array());
Array ( [rows] => Array ( [0] => Array ( [DT_RowId] => row_9684 [ocorder] => Array ( [id] => 9684 [factory] => 鏌忛槼 [ddbh] => 6002 [type1] => TPR [size] => 37 [sizediff] => [type2] => 鏃惰 [keyword] => [istax] => [wear] => [bjbz] => [bjr] => [bjdate] => [jgdate] => [mjdate] => [bjstau] => 姝e父 [hppic] => 19230209 [content1] => [removed_date] => ) [serviceshow4] => Array ( [name2] => 骞冲簳,钖勫簳,浣庤窡,涓窡,楂樿窡,鍧¤窡,璐磋窡,鎴峰,宸ヤ綔,椹竵闈�,鏃跺皻,浼戦棽,杩愬姩,浠€浣�,鍘氬簳 ) ) ) [row] => Array ( [DT_RowId] => row_9684 [ocorder] => Array ( [id] => 9684 [factory] => 鏌忛槼 [ddbh] => 6002 [type1] => TPR [size] => 37 [sizediff] => [type2] => 鏃惰 [keyword] => [istax] => [wear] => [bjbz] => [bjr] => [bjdate] => [jgdate] => [mjdate] => [bjstau] => 姝e父 [hppic] => 19230209 [content1] => [removed_date] => ) [serviceshow4] => Array ( [name2] => 骞冲簳,钖勫簳,浣庤窡,涓窡,楂樿窡,鍧¤窡,璐磋窡,鎴峰,宸ヤ綔,椹竵闈�,鏃跺皻,浼戦棽,杩愬姩,浠€浣�,鍘氬簳 ) ) [values] => Array ( [ocorder.factory] => 鏌忛槼 [ocorder.ddbh] => 6002 [ocorder.type1] => TPR [ocorder.size] => 37 [ocorder.sizediff] => [ocorder.type2] => 鏃惰 [ocorder.type3] => [ocorder.keyword] => [ocorder.bjbz] => [ocorder.istax] => [ocorder.bjstau] => 姝e父 [ocorder.content1] => [ocorder.hppic] => 19230209 [ocorder.removed_date] => ) ) [][]
Now, the returned NAME2 is a set of values for "Flat Bottom, Thin Bottom, Low Heel, Mid Heel, High Heel, Slope Heel, Fit Heel, Outdoor, Work, Martin Boots, Fashion, Leisure, Sports, Shijia, Thick Sole", but what I want to return is one of the values, such as "Flat Bottom". How do I split this NAME2
That's impressively hard to read and parse . Here it is rewritten:
Based on that,
$values
should be鏃惰
. Which has just let me to the error:The
if
condition should beif (! $values) {
!!Allan
Thank you. It is already possible to link, but now the output name2 is a set of numbers. What I want is that name2 is also a selection box, and the options in the selection box are separated by ",". At which position should we use the split function to separate this
It looks like countries2.php is now returning data.
I don't understand I'm afraid. Where is name2 on your page? And do you mean a
select
element withmultiple=true
which combines the selected values to be comma separated?Allan
Sorry, there was a problem with my expression. Now I have output. NAME2 is a dataset separated by, such as Mountainengineering, Fashion, Leisure, Sports. However, what I want to output is that NAME2 is a multi option SELECT with options such as Mountainengineering, Fashion, etc. I don't know where to separate this name2
I feel like it needs to be processed in the staff.php
staff.php ************************************(Part of the code)
The problem seems to be in this position
Field::inst( 'serviceshow4.name2' ),
Datasets with ',' signs are not separated here
Right - so the value stored in
ocorder.type2
is a string with a comma separated list of values? If that is the case use theseparator
andmultiple
option ofselect
- e.g.:Allan
yes, the value stored in is a string with a comma separated list of values ,It is for this field TYPE3 (serviceshow4.name2),The value of TYPE2 is correct and does not need to be separated
Okay - thanks. Is this now resolved, or do you have a further question on it?
Allan
Allan
Thank you for your continuous response. What I want to achieve is:
When the first red arrow corresponds to a dropdown selection of a column, the second red arrow should also be able to drop down. The dropdown items of this column are the values separated by "," here,
I don't know how to modify Field:: inst ('serviceshow4. name2 ') in order to achieve such a dropdown
Should the options of the second select change based on the value selected in the first? If so, see this blog post.
If you have two
select
elements dependent on each other, I would also strongly suggestion you show them both as editable at the same time. See this example for how to trigger inline editing on multiple cells at the same time.Allan
Thank you for your continuous response
Please check the latest URL
http://www.oceanshoes.com/temp/gborder.php
The latest countries2.php code is as follows
The secondary linkage is ready, they are working very well, and now there is only one problem left. The value of the secondary linkage is a string separated by "," ,such as "Baotou, Fashion, Fashion, Leisure, Sports", but I want these values to be separated by "," and "options. How can I modify them to achieve this?
For your column
分类
there is only ever one option shown in theselect
.Even if we were to split the value by comma, I don't understand where the options for that list should come from? How can there only be a single option for it, and that option is always selected. It seems like you need to resolve the list of options as the first priority. Unless I'm totally misunderstanding.
Allan
The separated list option is itself, which means separating its own fields into different list options through ","
It's already done, all the issues have been resolved. Thank you all