I am facing a tough condition, and i know that its realy going to be a tough one, but I am in no condition to solve it.
I want to show u all some db structure first
Table td_service
|-------------|---------------|---------------|
| service_id | service_title | pump |
|---------------------------------------------|
| 1 | Marine | 1,2 |
|---------------------------------------------|
| 2 | gas & Oil | 1,3 |
|---------------------------------------------|
Now table td_product
|-------------|---------------|---------------|
| product_id | product_title | category_id |
|---------------------------------------------|
| 1 | DB PUMP | 1 |
|---------------------------------------------|
| 2 | CG PUMP | 2 |
|---------------------------------------------|
| 3 | DH PUMP | 2 |
|---------------------------------------------|
and at last, the td_category table
|-------------|---------------|
| category_id | category_title|
|-----------------------------|
| 1 | Industry P |
|-----------------------------|
| 2 | Water Supply |
|-----------------------------|
| 3 | Extraction |
|-----------------------------|
Now the column pump in the table td_service is a string which contains the id of the pumps separated by a comma.
Now from each service I can get the list of the pumps and display them like this
$pump_list = $this->autoload_model->get_data_from_table("td_service","*","service_id = '$id'")->result_array();
$pump_list[0]['pump'] will have value 1,2
to list the pumps i can try explode operatipon on $pump_list[0]['pump']
$p_list = array();
$p_list = explode(",",$pump_list[0]['pump']);
foreach($p_list as $p)
{
$pump_info = $this->autoload_model->get_data_from_table("td_product","*","product_id = '$p'")->result_array();
echo $pump_info[0]['product_title'];
}
Now i want to show the pump names in this fashion
Industry P
-----------------------
DB PUMP, CG PUMP
when i search for a particular service id..
I cant just display the data in this grouping manner..
And one more thing, i have been strictly asked not to change the db structure.. Like some may suggest of making another table showing the relation between service and pump, but i cant do that as i have been restricted.