Hi All,
I'm trying to load data from a database into a combo box. MY current Code is this:
<input id="cc1" class="easyui-combobox" data-options="
valueField: 'fixture_id',
textField: 'custom_name',
url: 'combobox_fixture.php',
onSelect: function(rec){
var url = 'combobox_mode.php?id='+rec.id;
$('#cc2').combobox('reload', url);
}">
<input id="cc2" class="easyui-combobox" data-options="valueField:'mode_id',textField:'custom_mode'">
My PHP file looks like this:
<?php
//open connection to mysql db
$conn = @mysqli_connect(XXXXXXXX');
mysqli_select_db($conn, 'XXXXXXX');
//fetch table rows from mysql db
$sql = "select fixture_id, custom_name from fixture_details";
$result = mysqli_query($conn, $sql) or die("Error in Selecting " . mysqli_error($conn));
//create an array
$data = array();
while ( $row = $result->fetch_assoc() ){
$id = $row['fixture_id'];
$name = $row['custom_name'];
$data[] = ['fixture_id' => json_encode($id), 'custom_name' => json_encode($name)];
}
echo json_encode($data);
This is a sample output of the JSON encode:
[{"fixture_id":"\"19\"","custom_name":"\"MAC Viper Profile\""},{"fixture_id":"\"20\"","custom_name":"\"MAC Viper Wash\""},{"fixture_id":"\"21\"","custom_name":"\"Molefay Two Light\""},{"fixture_id":"\"22\"","custom_name":"\"Mythos\""},{"fixture_id":"\"23\"","custom_name":"\"Robin 100 LEDBeam\""},{"fixture_id":"\"24\"","custom_name":"\"Robin Pointe\""},{"fixture_id":"\"25\"","custom_name":"\"Source 4 - 25\\\/50 Zoom \""},{"fixture_id":"\"26\"","custom_name":"\"Arena Zoomspot Narrow\""},{"fixture_id":"\"27\"","custom_name":"\"Arena Theatre Fresnel\""},{"fixture_id":"\"28\"","custom_name":false},{"fixture_id":"\"29\"","custom_name":"\"StudioCOB FC\""},{"fixture_id":"\"30\"","custom_name":"\"ARRI Junior 1000\""},{"fixture_id":"\"31\"","custom_name":"\"MAC Quantum \""},{"fixture_id":"\"32\"","custom_name":"\"CE Source 4 - 25\\\/50 Zoom \""},{"fixture_id":"\"33\"","custom_name":"\"Mac Aura XB\""},{"fixture_id":"\"34\"","custom_name":"\"Sunstrip\""},{"fixture_id":"\"35\"","custom_name":"\"Lanta Fireball Par64\""},{"fixture_id":"\"36\"","custom_name":"\"P-5\""},{"fixture_id":"\"37\"","custom_name":"\"4 Cell Mole\""},{"fixture_id":"\"38\"","custom_name":"\"Atomic 3000\""},{"fixture_id":"\"39\"","custom_name":"\"Spikie\""},{"fixture_id":"\"40\"","custom_name":"\"Source 4\""},{"fixture_id":"\"41\"","custom_name":"\"Sceptron \\\/ LED Bars\""},{"fixture_id":"\"42\"","custom_name":"\"XLED RGBW\""},{"fixture_id":"\"43\"","custom_name":"\"Intella Storm 1000\""},{"fixture_id":"\"44\"","custom_name":"\"Pageant CM-600Z\""},{"fixture_id":"\"45\"","custom_name":"\"XP-1000WZ\""},{"fixture_id":"\"46\"","custom_name":"\"XP-20R BSW\""},{"fixture_id":"\"47\"","custom_name":"\"GL-6\""},{"fixture_id":"\"48\"","custom_name":"\"Stormy CC\""},{"fixture_id":"\"49\"","custom_name":"\"Rama 1.2kW Fresnel\""},{"fixture_id":"\"50\"","custom_name":"\"Mirror Ball\""},{"fixture_id":"\"51\"","custom_name":"\"R1 Wash\""},{"fixture_id":"\"52\"","custom_name":"\"Source 4\""},{"fixture_id":"\"53\"","custom_name":"\"Fresnel 1.2kW \""}]
This works, mostly, but all of the values that go into the combobox have "" around them.
1) How can I get rid of these?
2) Is there a way that I can do this with a text box instead of a combobox?