/web/generatedCode/simple-example/opencms/CMS_GROUPUSERS/listGridCMS_GROUPUSERS.php
PHP | 225 lines | 187 code | 35 blank | 3 comment | 27 complexity | bdce1448a8e417847ea649b5e2248cec MD5 | raw file
- <?php
- include_once("../common/dbConnection.php");
- include_once("../common/header.php");
- ?>
- <?
- $thisGROUP_IDFromForm = $_REQUEST['thisGROUP_IDField'];
- $thisAction = $_REQUEST['action'];
- if ($thisAction=="Update")
- {
- // Retreiving Form Elements from Form
- $thisGROUP_ID = addslashes($_REQUEST['thisGROUP_IDField']);
- $thisUSER_ID = addslashes($_REQUEST['thisUSER_IDField']);
- $thisGROUPUSER_FLAGS = addslashes($_REQUEST['thisGROUPUSER_FLAGSField']);
- $sqlUpdate = "UPDATE CMS_GROUPUSERS SET GROUP_ID = '$thisGROUP_ID' , USER_ID = '$thisUSER_ID' , GROUPUSER_FLAGS = '$thisGROUPUSER_FLAGS' WHERE GROUP_ID = '$thisGROUP_ID'";
- $resultUpdate = MYSQL_QUERY($sqlUpdate);
- echo "<b>Record with Id ".$thisGROUP_IDFromForm." has been Updated<br></b>";
- $thisGROUP_IDFromForm = "";
- }
- if ($thisAction=="Insert")
- {
- // Retreiving Form Elements from Form
- $thisGROUP_ID = addslashes($_REQUEST['thisGROUP_IDField']);
- $thisUSER_ID = addslashes($_REQUEST['thisUSER_IDField']);
- $thisGROUPUSER_FLAGS = addslashes($_REQUEST['thisGROUPUSER_FLAGSField']);
- $sqlInsert = "INSERT INTO CMS_GROUPUSERS (GROUP_ID , USER_ID , GROUPUSER_FLAGS ) VALUES ('$thisGROUP_ID' , '$thisUSER_ID' , '$thisGROUPUSER_FLAGS' )";
- $resultInsert = MYSQL_QUERY($sqlInsert);
- echo "<b>Record has been inserted in Database<br></b>";
- $thisGROUP_IDFromForm = "";
- }
- if ($thisAction=="Delete")
- {
- // Retreiving Form Elements from Form
- $thisGROUP_ID = addslashes($_REQUEST['thisGROUP_IDField']);
- $thisUSER_ID = addslashes($_REQUEST['thisUSER_IDField']);
- $thisGROUPUSER_FLAGS = addslashes($_REQUEST['thisGROUPUSER_FLAGSField']);
- $sqlDelete = "DELETE FROM CMS_GROUPUSERS WHERE GROUP_ID = '$thisGROUP_ID'";
- $resultDelete = MYSQL_QUERY($sqlDelete);
- echo "<b>Record with Id ".$thisGROUP_IDFromForm." has been Deleted<br></b>";
- $thisGROUP_IDFromForm = "";
- }
- $initStartLimit = 0;
- $limitPerPage = 10;
- $startLimit = $_REQUEST['startLimit'];
- $numberOfRows = $_REQUEST['rows'];
- $sortBy = $_REQUEST['sortBy'];
- $sortOrder = $_REQUEST['sortOrder'];
- if ($startLimit=="")
- {
- $startLimit = $initStartLimit;
- }
- if ($numberOfRows=="")
- {
- $numberOfRows = $limitPerPage;
- }
- if ($sortOrder=="")
- {
- $sortOrder = "DESC";
- }
- if ($sortOrder == "DESC") { $newSortOrder = "ASC"; } else { $newSortOrder = "DESC"; }
- $limitQuery = " LIMIT ".$startLimit.",".$numberOfRows;
- $nextStartLimit = $startLimit + $limitPerPage;
- $previousStartLimit = $startLimit - $limitPerPage;
- if ($sortBy!="")
- {
- $orderByQuery = " ORDER BY ".$sortBy." ".$sortOrder;
- }
- $sql = "SELECT * FROM CMS_GROUPUSERS".$orderByQuery.$limitQuery;
- $result = MYSQL_QUERY($sql);
- $numberOfRows = MYSQL_NUM_ROWS($result);
- ?>
- <?
- if ($numberOfRows==0) {
- ?>
- Sorry. No records found !!
- <?
- }
- else if ($numberOfRows>0) {
- $i=0;
- ?>
- <br>
- <?
- if ($_REQUEST['startLimit'] != "")
- {
- ?>
- <a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $previousStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Previous <? echo $limitPerPage; ?> Results</a>....
- <? } ?>
- <?
- if ($numberOfRows == $limitPerPage)
- {
- ?>
- <a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $nextStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Next <? echo $limitPerPage; ?> Results</a>
- <? } ?>
- <br><br>
- <TABLE CELLSPACING="0" CELLPADDING="3" BORDER="0" WIDTH="100%">
- <TR>
- <TD>
- <a href="<? echo $PHP_SELF; ?>?sortBy=GROUP_ID&sortOrder=<? echo $newSortOrder; ?>&startLimit=<? echo $startLimit; ?>&rows=<? echo $limitPerPage; ?>">
- <B>GROUP_ID</B>
- </a>
- </TD>
- <TD>
- <a href="<? echo $PHP_SELF; ?>?sortBy=USER_ID&sortOrder=<? echo $newSortOrder; ?>&startLimit=<? echo $startLimit; ?>&rows=<? echo $limitPerPage; ?>">
- <B>USER_ID</B>
- </a>
- </TD>
- <TD>
- <a href="<? echo $PHP_SELF; ?>?sortBy=GROUPUSER_FLAGS&sortOrder=<? echo $newSortOrder; ?>&startLimit=<? echo $startLimit; ?>&rows=<? echo $limitPerPage; ?>">
- <B>GROUPUSER_FLAGS</B>
- </a>
- </TD>
- </TR>
- <?
- if ($thisAction=="EnterNew")
- {
- ?>
- <FORM NAME="insertForm" METHOD="POST" ACTION="<? echo $_SERVER['PHP_SELF']; ?>">
- <input type="hidden" name="action" value="Insert">
- <input type="hidden" name="thisGROUP_IDField" value="<? echo $thisGROUP_ID; ?>">
- <TR BGCOLOR="#FF6666">
- <TD><input type"text" name="thisGROUP_IDField" value=""></TD>
- <TD><input type"text" name="thisUSER_IDField" value=""></TD>
- <TD><input type"text" name="thisGROUPUSER_FLAGSField" value=""></TD>
- <TD COLSPAN=2><input type="submit" name="Insert" Value="Insert Record"> </TD>
- </TR>
- </FORM>
- <?
- }
- ?>
- <?
- while ($i<$numberOfRows)
- {
- if (($i%2)==0) { $bgColor = "#FFFFFF"; } else { $bgColor = "#C0C0C0"; }
- $thisGROUP_ID = MYSQL_RESULT($result,$i,"GROUP_ID");
- $thisUSER_ID = MYSQL_RESULT($result,$i,"USER_ID");
- $thisGROUPUSER_FLAGS = MYSQL_RESULT($result,$i,"GROUPUSER_FLAGS");
- if ($thisGROUP_IDFromForm == $thisGROUP_ID)
- {
- ?>
- <FORM NAME="editForm" METHOD="POST" ACTION="<? echo $_SERVER['PHP_SELF']; ?>">
- <input type="hidden" name="action" value="Update">
- <input type="hidden" name="thisGROUP_IDField" value="<? echo $thisGROUP_ID; ?>">
- <TR BGCOLOR="<? echo $bgColor; ?>">
- <TD><input type"text" name="thisGROUP_IDField" value="<? echo $thisGROUP_ID; ?>"></TD>
- <TD><input type"text" name="thisUSER_IDField" value="<? echo $thisUSER_ID; ?>"></TD>
- <TD><input type"text" name="thisGROUPUSER_FLAGSField" value="<? echo $thisGROUPUSER_FLAGS; ?>"></TD>
- <TD COLSPAN=2><input type="button" name="Save" Value="Save" onClick="this.form.submit();"> </TD>
- </TR>
- </FORM>
- <?
- } else {
- ?>
- <TR BGCOLOR="<? echo $bgColor; ?>">
- <TD><? echo $thisGROUP_ID; ?></TD>
- <TD><? echo $thisUSER_ID; ?></TD>
- <TD><? echo $thisGROUPUSER_FLAGS; ?></TD>
- <TD><a href="<? echo $_SERVER['PHP_SELF']; ?>?action=Edit&thisGROUP_IDField=<? echo $thisGROUP_ID; ?>">Edit</a></TD>
- <TD><a href="<? echo $_SERVER['PHP_SELF']; ?>?action=Delete&thisGROUP_IDField=<? echo $thisGROUP_ID; ?>">Delete</a></TD>
- </TR>
- <?
- }
- ?>
- <?
- $i++;
- } // end while loop
- ?>
- </TABLE>
- <FORM NAME="insertForm" METHOD="POST" ACTION="<? echo $_SERVER['PHP_SELF']; ?>">
- <input type="hidden" name="action" value="EnterNew">
- <input type="Submit" name="submit" value="Insert New Record">
- </FORM>
- <br>
- <?
- if ($_REQUEST['startLimit'] != "")
- {
- ?>
- <a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $previousStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Previous <? echo $limitPerPage; ?> Results</a>....
- <? } ?>
- <?
- if ($numberOfRows == $limitPerPage)
- {
- ?>
- <a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $nextStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Next <? echo $limitPerPage; ?> Results</a>
- <? } ?>
- <br><br>
- <?
- } // end of if numberOfRows > 0
- ?>
- <?php
- include_once("../common/footer.php");
- ?>