My table '#__boats' is as follows:
id category type AIG ALLIANZ LLOYDS
1 0 Motorboats
2 0 Sailingboats
3 0 Jet Ski
4 1 up to 15hp 101,24
5 1 up to 25hp 88,32 86,96 118,11
6 1 26-30hp 89,32 87,96 119,11
7 1 31-50hp 90,32 88,96 120,11
8 2 51-70hp 107,64 104,35 168,74
9 2 71-75hp 111,78 104,35 168,74
10 3 76-100hp 111,78 104,35 168,74
The boathp element action is as follows:
function ff_boathp_action(element, action)
{
switch (action) {
case 'change':
jQuery('#ff_elem9589').empty();
jQuery.ajax({
type: "POST",
url: "https://myurl/boatspt.php",
data: {
boathp: element.value
},
success: function(data) {
var obj = JSON.parse(data);
var arr = obj;
jQuery('#ff_elem9589').append(jQuery('<option>', {
value: '',
text: 'Επιλέξτε τύπο πλωτού'
}));
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
jQuery('#ff_elem9589').append(jQuery('<option>', {
value: arr[i],
text: arr[i]
}));
}
}
});
break;
default:
;
} // switch
} // ff_boathp_action
In a .php I have the following:
$judgePick = JRequest::getVar('boathp');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('AIG,ALLIANZ,LLOYDS')
->from($db->quoteName('#__boats'))
->where($db->quoteName('type') . ' = ' . $db->quote($judgePick));
$db->setQuery($query);
$results = $db->loadAssocList();
if (!$results)
{
echo "No results";
}
else
{
echo json_encode($results);
}
If I use $results = $db->loadrow(); I get only the values of the row in question
If I add $columns = array_keys($results[0]); I get only the column names in question
but what I want to achieve in value descending order e.g. if the user requests 'type' = (up to 25hp), is the following:
ALLIANZ 86,96
AIG 88,32
LLOYDS 118,11
Thank you