can someone tell me how to insert the selected text not the value of a dropdown list (select box) into a mysql database when user hits the button enroll. The code right now inserts the id of the row i am rendering but I need to insert the value. Sorry if I am not that explanatory.. Much help is appreciated. !!!
Updated: Can Someone tell me how to redirect after succesfulling inserting to a confirmation page ?????
$db = &JFactory::getDBO();
$query = "
INSERT INTO
`jos_jquarks_persontraining`
(
course_name,
courseDate,
user_id,
employeeNumber,
department,
name,
timeStamp
)
VALUES
(
'{$courseTitle}',
'{$varcourseDate}',
'{$id}',
'{$username}',
'{$department}',
'{$name}',
'{$acknowledge}',
'{$vardate}'
)";
$db->setQuery($query);
$db->query();
if($db->getErrorNum()) {
JError::raiseError( 500, $db->stderr());
}
}
?>
<form name="quiz_info" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<?php
echo JText::_('Please select the date:');
$database= &JFactory::getDBO();
$database->setQuery('SELECT training_id,CONCAT(trainingDate,"-",trainingHour) AS trainingDate FROM training WHERE openSeats > 0');
$result = $database->loadObjectList();
echo '<select name="dateSelectBox">';
foreach ($result as $row) {
echo '<option value="'.$row->training_id.'">'.$row->trainingDate.'</option>';
}
echo '</select>';