Forums

Profile plugin populating list

d_proudfoot 04 Aug, 2009
I have read and re-read the instructions and searched though and read all the forum posts about the profile plugin and I am still confused. Could someone please explain in detail what I need to do to get the profile plugin to work. I have a database that I have created with lesson choices. I want this list to be populated to a registration page so that people can choose which sessions that want to sign up for.
I am trying to figure out how to have a list of sessions and their descriptions with checkboxes beside them so that when they submit, I will know.
GreyHead 04 Aug, 2009
Hi d_proudfoot.

I'm not sure that the profile plugin is what you want here. I can see that the tooltip is not very clear - but in fact the plugin is designed to show just one record from a databse table e.g. profile info for one user.

To create a drop-down from a table you will need a little databse query to genreate the options. Here's an example
<?php
$event_selected = JRequest::getInt('event', '', 'post);
$db =& JFactory::getDBO();
$query = "
SELECT `event_id`, `event_name`
  FROM `#__gh_events`
  ORDER BY `event_name`
";
$db->setQuery($query);
$events = $db->loadAssocList();
$event_options = "";
foreach ( $events as $v ) {
  if ( $even_selected == $v['event_id'] ) {
    $selected = "selected='selected'";
  } else { 
    $slected = '';
  }
  $event_options .= "<option value='".$v['event_id']."' $selected >".$v['event_name']."</option>";
}
?>
<!-- Events -->
<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Het was dit event</label>
    <select class="cf_inputbox" id="select_4" size="1" title=""  name="event">
    <option value="">--?--</option>
<?php
echo $event_options;
?>
    </select>
  </div>
  <div class="cfclear"> </div>
</div>

Bob
This topic is locked and no more replies can be posted.