blob: ba09bb31c9e75566faa11d51160c4aa28f16ac0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
require_once('db-connect.php');
if(isset($_POST['catid'])) {
$query = "SELECT pre.id, pre.book, author FROM textbook_companion_preference pre WHERE pre.approval_status=1 AND pre.category=".$_POST['catid']." AND cloud_pref_err_status=0 and pre.proposal_id IN (SELECT id from textbook_companion_proposal where proposal_status=3) ORDER BY pre.book ASC";
$result = mysql_query($query);
$data = '<select id="books" name="books">';
$data .= '<option value="">-- Select book --</option>';
$counter = 1;
while($row = mysql_fetch_object($result)){
$counter_str = '';
if($counter < 10) {
$counter_str = ' '.$counter.'. ';
}elseif($counter < 100) {
$counter_str = ' '.$counter.'. ';
}else {
$counter_str = $counter.'. ';
}
$data .= '<option value="' . $row->id . '">' . $counter_str . $row->book . ' (' . $row->author . ')</option>';
$counter++;
}
$data .= '</select>';
echo $data;
exit;
}elseif(isset($_POST['bid'])) {
$query = "select id, name, number from textbook_companion_chapter where cloud_chapter_err_status=0 and preference_id=".$_POST['bid']." order by number ASC";
$result = mysql_query($query);
$data = '<select name="chapter" id="chapter">';
$data .= '<option value="">-- Select chapter --</option>';
while($row = mysql_fetch_object($result)){
$data .= '<option value="' . $row->id . '">' . $row->number . ' - ' . $row->name . '</option>';
}
$data .= '</select>';
echo json_encode($data);
exit;
}elseif(isset($_POST['cid'])) {
$query = "select id, caption, number from textbook_companion_example where cloud_err_status=0 and chapter_id=".$_POST['cid'];
$result = mysql_query($query);
$data = '<select name="example" id="example">';
$data .= '<option value="">-- Select an example --</option>';
while($row = mysql_fetch_object($result)) {
$data .= '<option value="' . $row->id . '">' . $row->number . ' - ' . $row->caption . '</option>';
}
$data .= '</select>';
echo json_encode($data);
exit;
}
?>
|