CodeIgniter Forums
multiple dropdowns - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: multiple dropdowns (/showthread.php?tid=38465)



multiple dropdowns - El Forum - 02-08-2011

[eluser]RobertB.[/eluser]
MySql
Code:
SELECT se.service_id, se.service, pr.price, s2p.description
FROM sw_service2price s2p
LEFT JOIN sw_services se ON s2p.serviceId = se.service_id
LEFT JOIN sw_service2interval s2i ON se.service_id = s2i.serviceId
LEFT JOIN sw_prices pr ON s2p.priceId = pr.price_id
WHERE s2i.intervalId =1

Result * Is correct.

ID Services Prices Desc
-------------------------------------
1 | Service 1-1 | 22.95 | desc 1-1
1 | Service 1-2 | 29.95 | desc 1-2
2 | Service 2-1 | 59.95 | desc 2-1

The Question -
How can I make both services with the ID of 1 in one dropdown and the one with the ID of 2 on a different dropdown, is this possible?

I'm trying to use ajax but I only get one dropdown with all 3 items
This is part of the code in my controller
Code:
$interval = $this->input->post('interval');
$data['services'] = $this->iSelector->getServices($interval);

$data['output'] = '';
foreach($data['services'] as $service){
$data['output'] .= '<option value="">'.$service->service.'</option>';
}

echo json_encode($data);