function getAnswers($phraseID, $drill) { include 'config.php'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); $qBlanks = getBlanks($phraseID, 'fill_in_the_blank'); $blankCounter = 1; for ($i = 0; $i < $qBlanks; $i++) { if ($drill == "adj" || $drill == "wordBox") { $answers[] = getAdjAnswer($phraseID, $blankCounter); } elseif ($drill == "fib") { $answers[] = getAnswer(getAnswerID($phraseID, $blankCounter)); } $blankCounter++; } return $answers; }
<div class="fibStitleInner" id="fibchoiceTitle"> <div class="fibSent"> <span style="text-decoration:underline;">Question id: <?php echo $fibWord['id']; ?> </span> <!--<span class="pull-right" style="text-decoration:underline;"><?php echo $_SESSION['qCount']; ?> <small>Completed</small></span>--> <h1><?php for ($i = 0; $i <= getBlanks($fibWord['id'], 'fib_word'); $i++) { echo $choppedPhrase[$i]; $maxLength = $_POST['type'] == 'particle' ? 3 : 15; $size = $_POST['type'] == 'particle' ? 2 : ($_POST['type'] == 'adverb' ? 8 : ($_POST['type'] == 'verb' ? 20 : 15)); if ($i != getBlanks($fibWord['id'], 'fib_word')) { ?> <input type='text' class="text-center" name='<?php $j = $i + 1; echo "word" . $j; ?> ' <?php if ($_POST['type'] == 'verb') { ?> class="fibVIn"<?php } elseif ($_POST['type'] == 'particle') { ?> class="fibPIn"<?php } ?> id='<?php
function getFIBAdjWordRChoices($phraseID, $col, $table) { include 'config.php'; require_once 'blanks.php'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); $blankQ = getBlanks($phraseID, 'fib_word'); //get each blanks' answer $query = sprintf("SELECT %s FROM %s WHERE element_id ='%s'", mysql_real_escape_string($col), mysql_real_escape_string($table), mysql_real_escape_string($phraseID)); $result = mysql_query($query) or die(mysql_error()); for ($i = 0; $i < $blankQ; $i++) { list($value[$i]) = mysql_fetch_row($result); /*everytime it fetches the row, adds it to array...*/ //fetch probably goes through each location of $result array } return $value; }