Forums

drop down multiple selection

daisy 02 Oct, 2009
hi.
i am using chronoform so, i would to ask how to create php code in this query so that it will display more than one category?i have tried but it only display one category even i chose two category.
below is an example code of submit form from user.
<select name="Category" multiple="multiple" >
    <option value ="-Select-">-Select-</option>
    <option value="Arts & Entertaiment">Arts & Entertaiment</option>
    <option value="Business & Professional Services">Business & Professional  Services</option>
    <option value="Clothing & Accessories">Clothing & Accessories</option>
    </select>


and this one is the query which will display submitted form from user.I guess something's wrong with this query but not sure how to correct it.
<?
  $query = "select * from jos_chronoforms_submit_listing_page where txtCat LIKE '%Arts & Entertaiment%' ";
  $result = mysql_query($query);
 

  while($query_data=mysql_fetch_array($result))
{
  $txt1 = $query_data["txtCat"];

echo "$txt1";
}
?>
GreyHead 02 Oct, 2009
Hi daisy,

First, we always recommend that you use the Joomla Database code to access your data. It is more secure and more portable.
<?php
$db =& JFactory::getBDO();
$query = "
  SELECT * 
    FROM `#__chronoforms_submit_listing_page`
    WHERE `txtCat` LIKE '%Arts & Entertainment%' ;
";
$db->setQuery($query);
$result = $db->loadAssocList();

foreach ( $result as $k => $v ) {
  echo $v['txtCat'];
}
?>

Bob
daisy 02 Oct, 2009
ok..thanks a lot..it works!
This topic is locked and no more replies can be posted.