Hi All,
i have this problem:
i'm opening a form passed data POST the string [azienda] (is a number code, on this case: 406)
I'm trying to create a Json code for Autocompleter with this data but it doesn't work.
If i print DATAPOST on a form, works fine, but in Json not.
This is my Json code for autocompleter:
Any ideas?
i have this problem:
i'm opening a form passed data POST the string [azienda] (is a number code, on this case: 406)
I'm trying to create a Json code for Autocompleter with this data but it doesn't work.
If i print DATAPOST on a form, works fine, but in Json not.
This is my Json code for autocompleter:
<?php
$cod_azie = $_POST['azienda'];
$db = JFactory::getDbo();
$db->setQuery("SELECT * FROM xcsri_ana_intranet WHERE
cod_azie = $cod_azie
");
$results = $db->loadObjectList();
foreach($results as $result ){
if(!empty($form->data['tag']) AND stripos($result->nominativo, $form->data['tag']) === false){
continue;
}
$json[] = array('id' => $result->id, 'text' => $result->nominativo);
}
echo json_encode($json);
Any ideas?
i forget ot say: if i write $cod_azie = 406; it works........
Hi andreasuriani,
You haven't defined $json anywhere - that will give a problem with recent PHP versions. Try
Bob
You haven't defined $json anywhere - that will give a problem with recent PHP versions. Try
$results = $db->loadObjectList();
$json = array();
. . .
Bob
Hi Bob,
sorry to be late๐
I've tried but unfortunately doesn't work.
Why?๐
sorry to be late๐
I've tried but unfortunately doesn't work.
<?php
$cod_azie = $_POST['cod_azie'];
$db = JFactory::getDbo();
$db->setQuery("SELECT * FROM xcsri_ana_intranet WHERE cod_azie = '" . $cod_azie . "' AND check_conguagliato IS NULL ORDER BY nominativo ASC");
$results = $db->loadObjectList();
$json = array();
foreach($results as $result ){
if(!empty($form->data['tag']) AND stripos($result->nominativo, $form->data['tag']) === false){
continue;
}
$json[] = array('id' => $result->codice_fiscale, 'text' => $result->nominativo);
}
echo json_encode($json);
Why?๐
This topic is locked and no more replies can be posted.