**Tablo Adı 'reference'**
```
id:58
referencetitle :helloword 1
id:59
referencetitle :helloword 2
```
--------------
**Tablo Adı 'reference_categories'**
```
category_id: 92
category_name: word category 1
category_id: 93
category_name: word category 2
category_id: 94
category_name: word category 3
category_id: 95
category_name: word category 4
category_id: 96
category_name: word category 5
```
----------------
**Tablo Adı 'ref_sel_categories'**
```
id:1
reference_id:58
reference_category_id:92
id:2
reference_id:58
reference_category_id:93
id:3
reference_id:59
reference_category_id:94
id:4
reference_id:59
reference_category_id:94
id:5
reference_id:59
reference_category_id:94
```
$id = get('id');
$row = $db->from('reference')
->where('reference_id', $id)
->first();
$categories = $db->from('reference_categories')
->orderby('category_name', 'ASC')
->all();
$selectcategory = $db->from('ref_sel_categories')
->where('reference_id', $id)
->first();
if (post('submit')) {
$PostCategories = post('reference_categories');
if (!isset($error)) {
foreach ($_POST[$PostCategories as $selectedOption)
{
$update = $db->update('ref_sel_categories')
->where('reference_id', $id)
->set([
'reference_category_id' => $selectedOption,
]);
}
}
}
require 'edit-reference';