navigation  interaction  search

 other resources

root/tags/phpbms-0.62/choicelist.php

Revision 77 (checked in by mipalmer, 2 years ago)

Reorganizing for multiple projects

Line 
1 <?php
2 /*
3  +-------------------------------------------------------------------------+
4  | Copyright (c) 2005, Kreotek LLC                                         |
5  | All rights reserved.                                                    |
6  +-------------------------------------------------------------------------+
7  |                                                                         |
8  | Redistribution and use in source and binary forms, with or without      |
9  | modification, are permitted provided that the following conditions are  |
10  | met:                                                                    |
11  |                                                                         |
12  | - Redistributions of source code must retain the above copyright        |
13  |   notice, this list of conditions and the following disclaimer.         |
14  |                                                                         |
15  | - Redistributions in binary form must reproduce the above copyright     |
16  |   notice, this list of conditions and the following disclaimer in the   |
17  |   documentation and/or other materials provided with the distribution.  |
18  |                                                                         |
19  | - Neither the name of Kreotek LLC nor the names of its contributore may |
20  |   be used to endorse or promote products derived from this software     |
21  |   without specific prior written permission.                            |
22  |                                                                         |
23  | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     |
24  | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       |
25  | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
26  | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
27  | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
28  | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
29  | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
30  | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
31  | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
32  | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
33  | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
34  |                                                                         |
35  +-------------------------------------------------------------------------+
36 */
37     require_once("include/session.php");
38     
39     function deleteList($listname){
40         global $dblink;
41
42         $querystatement="DELETE FROM choices WHERE listname=\"".$listname."\" ";
43         $queryresult=mysql_query($querystatement,$dblink);
44         if(!$queryresult)
45             reportError(100,"SQL Statement Could not be executed.");
46         else
47             echo "ok";
48     }
49     
50     function addToList($listname,$value){
51         global $dblink;
52
53         $querystatement="INSERT INTO choices (listname,thevalue) VALUES(\"".$listname."\",\"".$value."\") ";
54         $queryresult=mysql_query($querystatement,$dblink);
55         if(!$querystatement)
56             reportError(100,"SQL Statement Could not be executed.");
57         else
58             echo "ok";
59     }
60
61     function displayList($queryresult,$blankvalue){
62         while($therecord=mysql_fetch_array($queryresult)){
63             $display=$therecord["thevalue"];
64             $theclass="";
65             if($therecord["thevalue"]==""){
66                 $display="&lt;".$blankvalue."&gt;";
67                 $theclass=" class=\"choiceListBlank\" ";
68             }
69             ?><option value="<?php echo $therecord["thevalue"]?>" <?php echo $theclass?>><?php echo $display?></option><?php
70         }//end while
71     
72     }
73     
74     function displayBox($listname,$blankvalue,$listid){
75         global $dblink;
76         
77         $blankvalue=str_replace("<","",$blankvalue);
78         $blankvalue=str_replace(">","",$blankvalue);
79         
80         $querystatement="SELECT thevalue FROM choices WHERE listname=\"".$listname."\" ORDER BY thevalue;";
81         $queryresult=mysql_query($querystatement,$dblink);
82         if(!$querystatement) reportError(100,"SQL Statement Could not be executed.");
83 ?>
84     <table width="100%" cellpadding="0" cellspacing="0">
85         <tr>
86             <td valign="top"><select id="MLlist" name="MLList" size="12" style="width:230px;margin-right:10px;margin-bottom:10px;" onChange="updateML(this)"><?php displayList($queryresult,$blankvalue)?>
87             </select></td>
88             <td valign="top" style="width:100%">
89             <input type="button" id="MLDelete" name="MLDelete" value="delete" class="Buttons" style="width:50px;;margin-bottom:5px;" disabled onClick="delML()" /><br/>
90             <input type="button" id="MLInsert" name="MLInsert" value="insert" class="Buttons" style="width:50px" onClick="insertML()"/>
91             </td>
92             <tr>
93                 <td valign="top">
94                     <input name="MLaddedit" id="MLaddedit" type="text" style="width:220px;margin-right:10px;margin-bottom:5px;"/>
95                     <input name="MLblankvalue" id="MLblankvalue" type="hidden" value="<?php echo $blankvalue?>"/>
96                 </td>
97                 <td valign="top"><input type="button" id="MLaddeditbutton" name="MLaddeditbutton" value="add" class="Buttons" style="width:50px" onClick="addeditML('<?php echo $blankvalue?>')" /></td>
98             </tr>
99         </tr>
100     </table>
101     <div id="MLStatus" class="small" align="center">&nbsp;</div>
102     <div align="right">
103         <input type="button" id="MLok" name="MLok" value="ok" class="Buttons" style="width:75px;" onClick="clickOK('<?php echo $_SESSION["app_path"]?>','<?php echo $listid?>','<?php echo $listname?>')"/>
104         <input type="button" id="MLcancel" name="MLcancel" value="cancel" class="Buttons" style="width:75px;" onClick="closeBox('<?php echo $listid?>');"/>&nbsp;
105     </div>
106 <?php    }//end function
107
108     if(!isset($_GET["cm"]))
109         $_GET["cm"]="shw";
110     
111     if(!isset($_GET["ln"]))
112         $_GET["ln"]="shippingmethod";
113     if(!isset($_GET["bv"]))
114         $_GET["bv"]="none";
115     switch($_GET["cm"]){
116         case "shw":
117             displayBox($_GET["ln"],$_GET["bv"],$_GET["lid"]);
118         break;
119         case "del":
120             deleteList($_GET["ln"]);
121         break;
122         case "add":
123             addToList($_GET["ln"],$_GET["val"]);
124         break;
125     }
126     
127 ?>
Note: See TracBrowser for help on using the browser.
Copyright © 2006-2007 Kreotek, LLC. All Rights reserved.