PHP Classes

File: crud360_example4.php

Recommend this page to a friend!
  Classes of Muhammad Usman  >  PHP CRUD 360 Form Generator  >  crud360_example4.php  >  Download  
File: crud360_example4.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP CRUD 360 Form Generator
Generate forms for administration panels
Author: By
Last change:
Date: 3 years ago
Size: 2,215 bytes
 

Contents

Class file image Download
<?php
// EXAMPLE 4
include_once("crud360/includes/class.crud360.php");
//Check if we are in page
if(Crud360::pageMode())
{
   
$table_name=Crud360::$crud360[$_GET[Crud360::$crud360Get]];
   
$table = new Crud360($table_name);
   
    switch(
$table_name)
    {
        case
"users" :
        {
           
$table->columns(["name","email","department_id","status_id"]);
           
$table->setLookupFields("status_id","statuses","id","title");
           
$table->setLookupFields("department_id","departments","id","title");
           
$table->title("department_id","Department");
           
$table->title("status_id","Status");
            break;
        }
        case
"statuses" :
        {
           
$table->columns(["title"]);
           
$table->heading("Status");

           
$table->title("title","Status");
            break;
        }
        case
"departments" :
        {
           
$table->columns(["title"]);
           
$table->title("title","Department");
            break;
        }

        default :
        {
           
        }
       
    }

   
//!!!!MAKE SURE TO CALL THIS AFTER YOU HAVE SET ALL THE OPTIONS JUST BEFORE YOUR HTML BEGINS
    //This call processes all form requests for all the objects
   
Crud360::process([$table]);
}
//Include bootstrap, datepicker, and essential crud360
include_once("crud360/inc/header.php");
?>
<?php
include_once("crud360/inc/nav.php");?>
<div class="container">
<h3 align="center"><strong>Example 4:</strong> All database tables using a single loop on a single page with navigation!</h3>
<?php Crud360::defaultDivs(); ?>
<div class="row">
        <div class="col-md-3">
            <div style="padding:15px;background:#f3f3f3;">
            <?php
           
                Crud360
::showAllLinks();
           
?>
<hr>
            <?php
                Crud360
::showSingleLink("users","Single Link for Users");
           
?>
           <hr>
           </div>

        </div>
        <div class="col-md-9">
           <?php
       
// this method must be called within a renderable region of an html page, it displays records, creates neccessary forms etc...
       
if(Crud360::pageMode())
        {
           
$table->magic();
        }
        else
        {
           
?>
<p align="center">Click on one of the links to begin!</p>
            <?php
       
}
       
?>
</div>
    </div>
<?php Crud360::renderSource(__FILE__) ; // display source of this current file ?>
</div>
<?php include_once("crud360/inc/footer.php"); ?>
<?php
if(Crud360::pageMode())
{
   
Crud360::javascript([$table]);
}
?>

For more information send a message to info at phpclasses dot org.