how to insert drop down selected value into database - Joomla! Forum - community, help and support
i have multiple drop-down boxes, drop-downs data different categories. retrieve data using select query , id , name categories tables.
three drop down. motherboard contain motherboards (total 10)
processor contain processor
ram contain rams
when user select motherboard uisng dropdown.. related motherboard fetch database using ajax call working fine.
but when select motherboard, processor , ram list , save.. id's save database.
but these id's drop-downs list last item(because of foreach loop).. , not selected items.
how insert selected value database
second after inserting correct ids how update id when change motherboards or processor
i trying insert , update this..
i inserting , updating joomla's using object
please give me hint.. take time.. still have no success
here how insert value database
best regards
code: select all
<select name="m_id" id="m_id" onchange="showuser(this.value)">
<option value="">select motherboard:</option>
<?php foreach ($results $row)
{
echo '<option value="'.$row->virtuemart_product_id.'">'.$row->product_name.'</option>';
}
?>
</select> three drop down. motherboard contain motherboards (total 10)
processor contain processor
ram contain rams
when user select motherboard uisng dropdown.. related motherboard fetch database using ajax call working fine.
but when select motherboard, processor , ram list , save.. id's save database.
but these id's drop-downs list last item(because of foreach loop).. , not selected items.
how insert selected value database
second after inserting correct ids how update id when change motherboards or processor
i trying insert , update this..
code: select all
<select name="m_id" id="m_id" onchange="showuser(this.value)">
<option value="">select motherboard:</option>
<?php foreach ($results $row)
{
echo '<option value="'.$insert->m_id=$row->virtuemart_product_id.'">' .$row->product_name.
'</option>';
$update->m_id = $row->virtuemart_product_id;
}
?>
</select> i inserting , updating joomla's using object
please give me hint.. take time.. still have no success
here how insert value database
code: select all
<?php
$options = array();
$options[] = "<option value=''>--?--</option>";
$db =& jfactory::getdbo();
$query = $db->getquery(true);
$query->select(array('a.virtuemart_product_id, a.product_name, b.virtuemart_category_id', 'c.published' , 'c.product_sku'));
$query->from('#__virtuemart_products_en_gb a');
$query->join('left', '#__virtuemart_product_categories b on (a.virtuemart_product_id = b.virtuemart_product_id)' );
$query->join('right', '#__virtuemart_products c on (a.virtuemart_product_id = c.virtuemart_product_id)' );
$query->where('b.virtuemart_category_id = '.$mid, 'and')
->where('c.published = ' .$publish );
$db->setquery($query);
$data = $db->loadobjectlist();
foreach ( $data $d ) {
$options[] = '<option value="'.$d->virtuemart_product_id.'">'.$d->product_name.'</option>';
}
?>
<select class="inputbox" id="m_id" name="m_id" size="1">
<?php echo implode("\n", $options);
// insert db
$profile = new stdclass();
$profile->virtuemart_product_id = $this->product->virtuemart_product_id;
$profile->m_id = $d->virtuemart_product_id;
try {
$result = jfactory::getdbo()->insertobject('#__virtuemart_deals', $profile);
}
catch (exception $e) {
// catch errors.
}
?>
</select>best regards
Comments
Post a Comment