What's new

Welcome to xCrud Community - Data Management and extended PHP CRUD

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Database Driven Combo Lookup

Bradn

New member
Joined
Apr 24, 2024
Messages
5
Reaction score
0
Points
1
Location
Australia
I have this database driven Combo Lookup:

//START COMBO
$sql = "select * from CourseType where hidden='No' order by name";
$active = db_select_query($sql);
unset($combolist);

foreach ($active as $recordvalue) {
$combolist[] = array($recordvalue['coursetypeid'] => $recordvalue['name']);
};

$xcrud->change_type('coursetype','select','', $combolist);
//END COMBO

The problem I have is the output is:

0
Value
1
Value
2
VAlue
etc

Where
VALUE is correct and the correct value is recorded
0,1,2 Is read only/disabled and I have no idea where this comes from or how to get rid of it!
(image attached)

Any ideas on how to remove this index?
 

Attachments

  • combo.jpg
    combo.jpg
    22.7 KB · Views: 5

DaDo

Administrator
Staff member
Joined
Dec 1, 2021
Messages
108
Reaction score
23
Points
18
I have this database driven Combo Lookup:

//START COMBO
$sql = "select * from CourseType where hidden='No' order by name";
$active = db_select_query($sql);
unset($combolist);

foreach ($active as $recordvalue) {
$combolist[] = array($recordvalue['coursetypeid'] => $recordvalue['name']);
};

$xcrud->change_type('coursetype','select','', $combolist);
//END COMBO

The problem I have is the output is:

0
Value
1
Value
2
VAlue
etc

Where
VALUE is correct and the correct value is recorded
0,1,2 Is read only/disabled and I have no idea where this comes from or how to get rid of it!
(image attached)

Any ideas on how to remove this index?
try this
PHP:
// Inizializza l'array $combolist
$combolist = [];

// Itera sui risultati della query
foreach ($active as $recordvalue) {
    $combolist[$recordvalue['coursetypeid']] = $recordvalue['name'];
}

$xcrud->change_type('coursetype', 'select', '', $combolist);
 
Top Bottom