I'm a very inexpert php programmer, I ve done some asp.internet programming but never php.

I want the necessity to give a dropdownlist with values from the table within the mysql database. I by hand produced a table training: id training date hour openseats

And I have to display this dates and hour within the dropdownlist, so when the user clikc submits this get saved right into a table known as jos_jquarks_customers_acknowledge

Are you able to assist me to how you can pupulate the dropdown?

Code:

{source}
<!-- You can place html anywhere within the source tags -->
<?php 
// If the constant _JEXEC is not defined, quit now.
// This stops this script from running outside of the system.
defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<?php

$user = JFactory::getUser(); 
$id = $user->get('id'); 
$name = $user->get('name');
$username = $user->get('username'); 
$department = $user->get('department');

$vardate = date("Y-m-d H:i:s");

$acknowledge = 1;
$courseTitle = $mainframe->getPageTitle();

$courseDate = ;
$courseHour =;


/***************************************/

$db = &JFactory::getDBO();

$query = "
INSERT INTO
`jos_jquarks_users_acknowledge`
(
course_name,
user_id,
employeeNumber,
department,
name,
acknowledge,
timeStamp,courseDate,
courseHour
)
VALUES
(
'{$courseTitle}',
'{$id}',
'{$username}',
'{$department}',
'{$name}',
'{$acknowledge}',
'{$vardate}',
'{$courseDate}',
'{courseHour}'

 )";

$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::_('Do you want to enroll into the course?') ; ?>

<? $queryCourses="SELECT training_id,training,trainingDate FROM training"; ?>

$result = mysql_query ($queryCourses); 
echo "<select name=courseDates value=''>Date</option>"; 
// printing the list box select command 

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt 
echo "<option value=$nt[id]>$nt[training]</option>"; 
/* Option values are added by looping through the array */ 
} 
echo "</select>";//Closing of list box

<input id="proceedButton" name="proceedButton" value="Acknowledge" type="submit" />

<input type="hidden" name="layout" value="default" /> <?php echo JHTML::_( 'form.token' ); ?>

</form>

{/source}