MySQL

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesMySQL

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old January 1st, 2014, 05:51 PM
johnnygrr johnnygrr is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2014
Posts: 1 johnnygrr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 21 sec
Reputation Power: 0
PHP Page populated by MySQL dropdowns

Hello,

I am trying to write a script to display records from an SQL database, but based on three variables which are set by three dropdown boxes on the page which are auto-populated from the database.

This is for a Learning Management System I am working on to provide effective feedback from online learning tests.

The code I am currently working on is below, along with the pseudo code which I hope will explain my requirements. The problem I am having is I cannot get the dropdown boxes to populate based on the criteria I have set in my pseudo code.

Any help is very much appreciated,
Thank you

John

Code:
// I used this article for the structure of the following script: 
http://forums.devarticles.com/mysql-development-50/drop-down-menu-populated-from-a-mysql-database-1811.html 

// Dropdown Box 1 - Choose the course - Show entries from the column "Name" from table "mdl_scorm". Once an option has been selected set variable $coursechoice to the value in the "id" column of the "mdl_scorm" table 

// Dropdown Box 2 - Choose the user - Show entries from the columns "firstname" + "lastname" from table "mdl_user" IF the number shown in the "id" column of table "mdl_user" is present in the "userid" column of table "mdl_scorm_scoes_track" AND IF $coursechoice is present in the "scormid" column of table "mdl_scorm_scoes_track". Once an option has been selected set variable $userchoice to the value in the "id" column of table "mdl_user" 

// Dropdown Box 3 - Choose the attempt - Show entries from the column "attempt" from table "mdl_scorm_scoes_track" IF $coursechoice is present in the "scormid" column of the table "mdl_scorm_scoes_track" AND IF $userchoice is present in the "userid" column of table "mdl_scorm_scoes_track". Once an option has been selected set variable $attemptchoice to the value in the "attempt" column from table "mdl_scorm_scoes_track" 

// Submit button displays the records from table "mdl_scorm_scoes_track" which have a value in the column "scormid" which matches $coursechoice AND have a value in the column "userid" which matches $userchoice AND have a value in the column "attempt" which matches $attemptchoice 

$sql="SELECT name FROM mdl_scorm"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

$id=$row["id"]; 
$thing=$row["name"]; 
$options.="<OPTION VALUE=\"$id\">".$thing; 
} 
?> 
<SELECT NAME=course> 
<OPTION VALUE=0>Choose the course 
<?=$options?> 
</SELECT> 
<?php 

$sql="SELECT username FROM mdl_user"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

$id=$row["id"]; 
$thing=$row["name"]; 
$options.="<OPTION VALUE=\"$id\">".$thing; 
} 
?> 
<SELECT NAME=user> 
<OPTION VALUE=0>Choose the user 
<?=$options?> 
</SELECT> 
<?php 

$sql="SELECT attempt FROM mdl_scorm_scoes_track"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

$id=$row["id"]; 
$thing=$row["name"]; 
$options.="<OPTION VALUE=\"$id\">".$thing; 
} 
?> 
<SELECT NAME=attempt> 
<OPTION VALUE=0>Choose the attempt 
<?=$options?> 
</SELECT> 
<?php 

$finalresult = SELECT element, value FROM mdl_scorm_scoes_track WHERE scormid=$coursechoice AND userid=$userchoice AND attempt=$attemptchoice 
while ($testrows = mysqli_fetch_array($finalresult)){ 
echo $testrows['value'];

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesMySQL > PHP Page populated by MySQL dropdowns


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap