A complete PHP process management instance code sharing

Source: Internet
Author: User
1. Add a new Process page:

<div> Select the process node: <br/><br/><?phpsession_start (); Include ("..    /dbda.class.php "); $db = new Dbda (); $suser =" SELECT * from users "; $auser = $db->query ($suser); foreach ($auser as $v) { echo "<input class= ' rd ' type= ' radio ' name= ' user ' value= ' {$v [0]} '/> {$v [2]} &nbsp;";}? &GT;&LT;/DIV&GT;&LT;BR/><div><input type= "button" value= "Add Node" id= "Jiedian"/></div><br/ ><div><?php$attr = Array (), if (!empty ($_session["user")) {$attr = $_session["user"];}    foreach ($attr as $k = + $v) {$sname = "select name from users where uid= ' {$v} '";        $name = $db->strquery ($sname); echo "<div>{$k}--{$name}--<input type= ' button ' value= ' delete ' bs= ' {$k} ' class= ' Shanchu '/></div> ';}? &GT;&LT;/DIV&GT;&LT;BR/><div> Please enter the process name: <input type= "text" id= "name"/></div><br/>< Input type= "button" value= "Save" id= "Xinjian"/><script type= "Text/javascript" >$ ("#jiedian"). Click (Function ( ) {//Selected withUser name var uid = "";        var rd = $ (". Rd"); for (Var i=0;i<rd.length;i++) {if (Rd.eq (i). Prop ("checked")) {uid = Rd.eq (i            ). Val (); }} $.ajax ({url: "chuli.php", data:{uid:uid,type:0}, Ty PE: "POST", DataType: "TEXT", success:function (data) {Window.location.href                = "add.php";        }            });        }) $ (". Shanchu"). Click (function () {var sy = $ (this). attr ("BS"); $.ajax ({url: "chuli.php", data:{sy:sy,type:1}, type: "POST", Da                Tatype: "TEXT", success:function (data) {window.location.href= "add.php";    }            });        }) $ ("#xinjian"). Click (function () {var name = $ ("#name"). Val ();      $.ajax ({url: "chuli.php", Data:{name:name,type:2},          Type: "POST", DataType: "TEXT", success:function (data) {WINDOW.L                Ocation.href= "add.php";    }            }); }) </script>

2. Add a new process (and other) processing page:

<?phpsession_start (); Include ("..        /dbda.class.php "), $db = new Dbda (), $type = $_post[" type "];switch ($type) {case 0: $uid = $_post[" UID "];        if (Empty ($_session["user"])) {$_session["user"] = array ($uid);            } else {$attr = $_session["user"];            $attr [] = $uid;        $_session["user"] = $attr;    } break;        Case 1: $sy = $_post["Sy"];        $attr = $_session["user"];        Unset ($attr [$sy]);        $attr = Array_values ($attr);        $_session["user"] = $attr;    Break        Case 2: $name = $_post["name"];        $code = time ();                  $SLC = "INSERT into Liucheng values (' {$code} ', ' {$name} ')";                Liucheng Name Code $db->query ($SLC, 0);        $attr = Array ();        if (!empty ($_session["user")) {$attr = $_session["user"]; } foreach ($attr as $k = + $v) {$SFP = "insert into Flowpath values (', ' {$Code} ', ' {$v} ', ' {$k} ');        Flowpath process specifically through who $db->query ($SFP, 0);    } break;        Case 3: $code = $_post["code"];        $nr = $_post["nr"];        $uid = $_session["UID"];        $RQ = time ();             $sql = "INSERT into Userflow values (' ', ' {$code} ', ' {$uid} ', ' {$nr} ', 0, ' {$rq} ', 0)";                                                                          Userflow process specific content, name, initiator $db->query ($sql, 0); , content, whether passed, events, to which step break;}

3. Log in to the top page:

<a href= "faqi.php" > Initiation process </a><table width= "100%" border= "1" cellpadding= "0" cellspacing= "0" > <tr&        Gt <td> Initiator </td> <td> Initiation time </td> <td> process name </td> <td> process content </td&gt        ;    <td> whether to end </td> <td> action </td> </tr> <?php session_start (); Include ("..    /dbda.class.php ");        $db = new Dbda ();        $uid = $_session["UID"];    $sql = "SELECT * from Userflow";        $attr = $db->query ($sql);                                                                                    foreach ($attr as $v) {$v [1];//Process Code $v [6];//Where did the process go? According to the process code and current login user name, check orders $szai = "SELECT count (*) from Flowpath where code= ' {$v [1]} ' an        D uids= ' {$uid} ';                $n = $db->strquery ($szai); The person under the process if ($n >0) {$sorder = "select orders from Flowpath where code= ' {$v [1]} ' and uids= ' {$            UID} ' "; $order = $db-&GT                        Strquery ($sorder);                if ($v [6]>= $order) {$str = "";                if ($v [6]== $order) {$str = "<a href= ' tongguo.php?ids={$v [0]} ' > through </a>"; } else {$str = "<span style= ' color:green ' > Processed </span&                gt; ";}        echo "<tr><td>{$v [2]}</td> <td>{$v [5]}</td> <td>{$v [1]}</td>            <td>{$v [3]}</td> <td>{$v [4]}</td> <td>{$str}</td></tr> "; }}}?> </table>

4. Launch the Process page:

4. Determine if the originating process is through the page:

<?phpsession_start (); Include (".. /dbda.class.php "); $db = new Dbda (); $ids = $_get[" IDs "]; $sql =" Update userflow set towhere = towhere+1 where ids= ' {$ids} ' " ; $db->query ($sql, 0); $STW = "Select Code,towhere from Userflow where ids= ' {$ids} '"; $ATW = $db->query ($STW); $  Lcdaihao = $ATW [0][0]; $towhere = $ATW [0][1]; $jiedian = "SELECT count (*) from Flowpath where code= ' {$lcdaihao} '"; $shuliang = $db->strquery ($jiedian), if ($towhere >= $shuliang) {    $su = "Update userflow set isOK =1 where ids= ' {$ids} '"; 
   $db->query ($su, 0);} Header ("location:main.php");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.