diff options
author | Jayaram R Pai | 2014-06-21 19:46:02 +0530 |
---|---|---|
committer | Jayaram R Pai | 2014-06-21 19:46:02 +0530 |
commit | 20a1808c6dce9ee019ae8f1c3e8a53577a00e712 (patch) | |
tree | 519da8b93e1f45a01873e6ca0621585c8f1ac6ef | |
parent | b72040ba0aa6d4320eb174dce12de1243071a991 (diff) | |
download | scilab_cloud_interface-20a1808c6dce9ee019ae8f1c3e8a53577a00e712.tar.gz scilab_cloud_interface-20a1808c6dce9ee019ae8f1c3e8a53577a00e712.tar.bz2 scilab_cloud_interface-20a1808c6dce9ee019ae8f1c3e8a53577a00e712.zip |
added feature to populate selects using eid in
-rwxr-xr-x | comment.php | 4 | ||||
-rw-r--r-- | get_elements.php | 83 | ||||
-rwxr-xr-x | index.php | 72 |
3 files changed, 133 insertions, 26 deletions
diff --git a/comment.php b/comment.php index f4197d6..75af061 100755 --- a/comment.php +++ b/comment.php @@ -14,8 +14,8 @@ echo "<p>Thank you for your valuable feedback.</p>"; - $to = "rush2jrp@gmail.com, mukulrkulkarni@gmail.com, lavitha89@gmail.com, kannan@iitb.ac.in, kiran@fossee.in, manasdas17@gmail.com"; - // $to = "rush2jrp@gmail.com, jayaram@iitb.ac.in"; + // $to = "rush2jrp@gmail.com, mukulrkulkarni@gmail.com, lavitha89@gmail.com, kannan@iitb.ac.in, kiran@fossee.in, manasdas17@gmail.com"; + $to = "rush2jrp@gmail.com, jayaram@iitb.ac.in"; $subject = "New Cloud Comment"; $message = " A new comment has been posted. <br> diff --git a/get_elements.php b/get_elements.php new file mode 100644 index 0000000..80078c9 --- /dev/null +++ b/get_elements.php @@ -0,0 +1,83 @@ +<?php + $elements = array(); + require_once('db-connect.php'); + + /* initializing variables */ + $chapter_id = 0; + $preference_id = 0; + $category_id = 0; + + function get_elements($example_id) { + /* retreving examples */ + $query = "SELECT id, caption, number, chapter_id FROM textbook_companion_example + WHERE cloud_err_status=0 AND chapter_id = ( + SELECT chapter_id FROM textbook_companion_example WHERE id = {$example_id} + ) + "; + $result = mysql_query($query); + $data = '<select name="example" id="example">'; + $data .= '<option value="">-- Select an example --</option>'; + while($row = mysql_fetch_object($result)) { + if($example_id == $row->id) $selected = "selected"; else $selected=""; + $data .= "<option value='{$row->id}' {$selected}>" . $row->number . ' - ' . $row->caption . '</option>'; + $chapter_id = $row->chapter_id; + } + $data .= '</select>'; + $data .= '<span id="example-download"> <a href="#">Download Example</a></span>'; + $elements["examples"] = $data; + + /* retreving chapters */ + $query = " + SELECT id, name, number, preference_id FROM textbook_companion_chapter + WHERE cloud_chapter_err_status=0 AND preference_id = ( + SELECT preference_id FROM textbook_companion_chapter WHERE id = {$chapter_id} + ) + 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)){ + if($chapter_id == $row->id) $selected = "selected"; else $selected=""; + $data .= "<option value='{$row->id}' {$selected}>" . $row->number . ' - ' . $row->name . '</option>'; + $preference_id = $row->preference_id; + } + $data .= '</select>'; + $data .= '<span id="chapter-download"> <a href="#">Download Chapter</a></span>'; + $elements["chapters"] = $data; + + /* retreving books*/ + $query = " + SELECT pre.id, pre.book, author, category FROM textbook_companion_preference pre + WHERE pre.approval_status=1 AND pre.category = ( + SELECT category FROM textbook_companion_preference WHERE id = {$preference_id} + ) 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.'. '; + } + if($preference_id == $row->id) $selected = "selected"; else $selected=""; + $data .= "<option value='{$row->id}' {$selected}>" . $counter_str . $row->book . ' (' . $row->author . ')</option>'; + $counter++; + $category_id = $row->category; + } + $data .= '</select>'; + $data .= '<span id="book-download"> <a href="#">Download Book</a></span>'; + $elements["books"] = $data; + $elements["category"] = $category_id; + + return $elements; + } +?> @@ -1,6 +1,10 @@ <?php - /*if(!$_GET['v']) - echo '<script type="text/javascript"> window.location="under-maintenance.html"; </script>';*/ + require "get_elements.php"; + $eid = 0; + if(isset($_GET["eid"]) && $_GET["eid"] != '') { + $eid = $_GET["eid"]; + $elements = get_elements($eid); + } ?> <html> <head> @@ -12,8 +16,8 @@ <script> $(document).ready(function(){ - var webroot = "http://cloud.scilab.in/"; - // var webroot = "http://localhost/cloud/"; + // var webroot = "http://cloud.scilab.in/"; + var webroot = "http://localhost/cloud/"; var imgdata = '<img src="images/ajax-loader.gif">'; $("#single_image").fancybox(); $('.fancymenu').fancybox({title: ""}); @@ -256,21 +260,29 @@ <tr> <td colspan="2"> <div class="lalg">Category</div> + <?php + function is_selected($nos) { + global $elements; + if($nos == $elements["category"]) { + return "selected"; + } + } + ?> <select id="categories" name="categories"> - <option value="">-- Select category --</option> - <option value="10">Analog Electronics</option> - <option value="3">Chemical Engineering</option> - <option value="12">Computer Programming</option> - <option value="2">Control Theory & Control Systems</option> - <option value="7">Digital Communications</option> - <option value="11">Digital Electronics</option> - <option value="8">Electrical Technology</option> - <option value="1">Fluid Mechanics</option> - <option value="9">Mathematics & Pure Science</option> - <option value="5">Mechanical Engineering</option> - <option value="6">Signal Processing</option> - <option value="4">Thermodynamics</option> - <option value="13">Others</option> + <option value="">-- Select category --</option> + <option value="10" <?php echo is_selected(10); ?>>Analog Electronics</option> + <option value="3" <?php echo is_selected(3); ?>>Chemical Engineering</option> + <option value="12" <?php echo is_selected(12); ?>>Computer Programming</option> + <option value="2" <?php echo is_selected(2); ?>>Control Theory & Control Systems</option> + <option value="7" <?php echo is_selected(7); ?>>Digital Communications</option> + <option value="11" <?php echo is_selected(11); ?>>Digital Electronics</option> + <option value="8" <?php echo is_selected(8); ?>>Electrical Technology</option> + <option value="1" <?php echo is_selected(1); ?>>Fluid Mechanics</option> + <option value="9" <?php echo is_selected(9); ?>>Mathematics & Pure Science</option> + <option value="5" <?php echo is_selected(5); ?>>Mechanical Engineering</option> + <option value="6" <?php echo is_selected(6); ?>>Signal Processing</option> + <option value="4" <?php echo is_selected(4); ?>>Thermodynamics</option> + <option value="13" <?php echo is_selected(13); ?>>Others</option> </select> <span id="contrib"> <a class="fancymenu" href="#acknowledge">+ Contributor</a></span> </td> @@ -278,22 +290,34 @@ <tr> <td colspan="2"> - <div id="lb" class="lalg"></div> - <div id="b"></div> + <div id="lb" class="lalg"> + <?php if($eid) echo "Book"; ?> + </div> + <div id="b"> + <?php if($eid) echo $elements["books"]; ?> + </div> </td> </tr> <tr> <td colspan="2"> - <div id="lc" class="lalg"></div> - <div id="c"></div> + <div id="lc" class="lalg"> + <?php if($eid) echo "Chapter"; ?> + </div> + <div id="c"> + <?php if($eid) echo $elements["chapters"]; ?> + </div> </td> </tr> <tr> <td colspan="2"> - <div id="le" class="lalg"></div> - <div id="e"></div> + <div id="le" class="lalg"> + <?php if($eid) echo "Chapter"; ?> + </div> + <div id="e"> + <?php if($eid) echo $elements["examples"]; ?> + </div> </td> </tr> |