rendered paste body<?php $this->pageTitle = 'Edit Gameshow'; global $lms; $lms = $pglms; function format_question($data, $i = null, $j = null) { global $lms; //return print_r($data, true); //pr($data); $question = 'Question: '.$data['question'][0].'<br>'; if ($data['type'] == 'multi') { $answers = array(); foreach ($data['choices']['choice'] as $num => $quest) { $correct = ($num == $data['answer'][0]); $img = $correct? 'check': 'x'; $img = $image = $lms->html->image("icons/$img.gif", array('border' => 0, 'width' => 16, 'height' => 16)); $answers[] = array($img, $quest[0]); } $question .= 'Answers: '.$lms->table(null, $answers); } else { $question .= 'Answers: '.$data['answer'][0]; } $edit = $lms->imagelink(LMS_BUTTON, ''.strtolower($data['type'].'/'.$i.'/'.$j), 'edit', 'edit', 25, 25, 'Edit'); $delete = $lms->imagelink(LMS_BUTTON, ''.strtolower('delete/'.$i.'/'.$j), 'delete', 'delete', 25, 25, 'Delete'); return $lms->align($edit, $delete).'<br>'.$question; } echo '<form name="roflcopter" method="post" action="'.$html->url('/gameshows/renamecat').'">'; $headers = array(); $questions = array(); $html->data['Categorys']['cat0'] = $gameshow[0]['name']; $html->data['Categorys']['cat1'] = $gameshow[1]['name']; $html->data['Categorys']['cat2'] = $gameshow[2]['name']; $html->data['Categorys']['cat3'] = $gameshow[3]['name']; foreach ($gameshow as $i => $category) { $headers[] = $html->input('Categorys/cat'.$i); if (!isset($category['quizitem'])) { $category['quizitem'] = array(); } if (array_key_exists(0, $category['quizitem'])) { foreach ($category['quizitem'] as $j => $quest) { $questions[$j][$i] = $quest; } } else { $questions[0][$i] = ($category['quizitem']); } } $rows = array(); foreach (range(0, 3) as $i) { foreach (range(0, 3) as $j) { if (!empty($questions[$i][$j])) { $rows[$i][$j] = format_question($questions[$i][$j], $i, $j); } else { if (empty($questions[$i][$j])) { $rows[$i][$j] = (!empty($questions[$i - 1][$j]))? array($pglms->addLink('New True/False Question', "truefalse/$i/$j"), $pglms->addLink('New Multiple Choice Question', "multi/$i/$j")): ''; if ($i == 0) { $rows[$i][$j] = array($pglms->addLink('New True/False Question', "truefalse/$i/$j"), $pglms->addLink('New Multiple Choice Question', "multi/$i/$j")); } } } } } echo $pglms->table($headers, $rows, array('border' => 1, 'class' => 'blueBorder')); echo $html->submit('Update Category Names', array('class' => 'submit')); echo '</form>'; //pr($gameshow); //pr($rows);?>