Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulate a PHP Dropdown List from MySQL Database in Joomla
    primarykey
    data
    text
    <p>I am a very inexpert php programmer, I ve done some asp.net programming but never php. </p> <p>I need the requirement to add a dropdownlist with values from a table in the mysql database. I manually created a table training: id training date hour openseats</p> <p>And I need to display this dates and hour in the dropdownlist, so once the user clikc submits this get stored into a table called jos_jquarks_users_acknowledge</p> <p>Can you help me how to pupulate the dropdown?</p> <p>Code:</p> <pre><code>{source} &lt;!-- You can place html anywhere within the source tags --&gt; &lt;?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' ); ?&gt; &lt;?php $user = JFactory::getUser(); $id = $user-&gt;get('id'); $name = $user-&gt;get('name'); $username = $user-&gt;get('username'); $department = $user-&gt;get('department'); $vardate = date("Y-m-d H:i:s"); $acknowledge = 1; $courseTitle = $mainframe-&gt;getPageTitle(); $courseDate = ; $courseHour =; /***************************************/ $db = &amp;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-&gt;setQuery($query); $db-&gt;query(); if($db-&gt;getErrorNum()) { JError::raiseError( 500, $db-&gt;stderr()); } ?&gt; &lt;form name="quiz_info" method="post" action="&lt;?php echo $_SERVER['REQUEST_URI']; ?&gt;"&gt; &lt;?php echo JText::_('Do you want to enroll into the course?') ; ?&gt; &lt;? $queryCourses="SELECT training_id,training,trainingDate FROM training"; ?&gt; $result = mysql_query ($queryCourses); echo "&lt;select name=courseDates value=''&gt;Date&lt;/option&gt;"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "&lt;option value=$nt[id]&gt;$nt[training]&lt;/option&gt;"; /* Option values are added by looping through the array */ } echo "&lt;/select&gt;";//Closing of list box &lt;input id="proceedButton" name="proceedButton" value="Acknowledge" type="submit" /&gt; &lt;input type="hidden" name="layout" value="default" /&gt; &lt;?php echo JHTML::_( 'form.token' ); ?&gt; &lt;/form&gt; {/source} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload