function api__getAllItems() { $items = array(); foreach (api__getQueries() as $q) { $list = api__getItems($q->id); //echo "<br />question#".$q->id." as ".count($list)." items"; foreach ($list as $item) { $items[] = $item; } } return $items; }
function getQuestions() { $qsts = api__getQueries(); $list = array(); for ($i = 0; $i < count($qsts); $i++) { $list[] = (array) $qsts[$i]; } $qsts = $list; if (count($qsts) < 1) { echo "Warning :: no questions returned"; } return (array) $qsts; }
public function reloadAll() { //echo "API :: reloaded all"; $this->queries = array(); $queries = api__getQueries(); for ($i = 0; $i < count($queries); $i++) { $q = $queries[$i]; $this->queries[$i] = array(); $this->queries[$i]["query"] = $q; $this->queries[$i]["items"] = $this->reload__items($q->id); } $this->save(); }
<?php include "includes.php"; ?> <?php $questions = api__getQueries(); ?> <div style="margin-left:50px;border-style:solid;width:500px;"> <form method="post" enctype="multipart/form-data" action="upload.php"> <input type="hidden" value="1" name="add-item" /> <select name="question-id"> <?php foreach ($questions as $q) { echo "<option value=\"" . $q->id . "\">QUESTION #" . $q->id . " -- " . $q->content . "</option>"; } ?> </select> <p>ITEM-TITLE<input name="title" /></p> <p>ITEM-DESCRIPTION<input name="description" /></p> <p><input name="file" id="file" type="file" /></p> <p><input type="submit" name="submit" /></p> </form> </div> <a href="index.php">BACK</a>