Create an approval system


#1

Hello everyone i am trying to make a Approval or decline system

i have got this code i have no clue how can i go about

doing this i seen a few on here but they are not what i want

i just like it to be like copy from addsite table

into main site table in mysqli also delete from addsite

code

 <table class="table table-striped" id="demo" width="100%" cellspacing="0">
                <thead>
                <tr>
                <th><center>demo7</center></th>
                <th><center>demo6</center></th>
                <th><center>demo5</center></th>
                <th><center>demo4</center></th>
                <th><center>demo3</center></th>     
                <th><center>demo2</center></th>
                <th><center>demo1</center></th>
                <th><center>Approve</center></th>   
                <th><center>decline</center></th>                                    
                <th><center>view site</center></th>                                    
                  </tr>
                </thead>
        <?php 
        //while($res = mysql_fetch_array($result)) { // mysql_fetch_array is deprecated, we need to use mysqli_fetch_array 
        while($row = mysqli_fetch_array($result)) { 
            echo  "<tr>";
            echo "<td><center>".$row['demo7']."</center></td>";
            echo "<td><center>".$row['demo6']."</center></td>";     
            echo "<td><center>".$row['demo5']."</center></td>";  
            echo "<td><center>".$row['demo4']."</center></td>";
            echo "<td><center>".$row['demo3']."</center></td>";     
            echo "<td><center>".$row['demo2']."</td></center>";
            echo "<td><center>".$row['demo1']."</td></center>";
            echo "<td><center><a href='".$row['id']."' class='btn btn-success'>Approve demo</a></br></center></td>";
            echo "<td><center><a href='".$row['id']."' class='btn btn-success'>decline demo</a></br></center></td>";
            echo "<td><center><a href='".$row['demo']."' class='btn btn-info'>View demo</a></center></td>";
           }
        ?>                 
        </table>         

#2

Some idea of your database layout might help people to suggest ideas. Exactly where will you store the “approve / decline” status in your database?


#3

i dont wanna store it i wanna move it from 1 table addsite to other table mainsite

so then it will get deleted from addsite and then shows in mainsite
for approval for decline it will just delete from table

here database


#4

Where are the values for the ref_adress and css columns supposed to come from?


#5

like i said there is 2 tables 1 addsite and 1 MAIN SITE tables in mysqli

i wanna move the one from addsite in mysql INTO main site table

so the admin approves the site then it goes to main site table so then
it will get deleted on admin panel so they wont see it any more
it will be on the main site table so users on frontend can see it


#6

I’m not so sure I would have designed the database the same way, but to clarify, the logic is similar to

  • a website is submitted
    • value INSERTed into the addsite table
  • website is reviewed and approved
    • value is removed from the addsite table
    • value is INSERTed into the main table

I’m not fond of sequential UPDATE and INSERT queries, but anyway, that’s what you’re after?


#7

Yes this is what i am looking for
also on 1 page as well if can be done
also i know its not the best way but i cant put 0 if not approved 1 if approved
as that would mess up my list


#8

Well the copying part is rather simple, you can use an INSERT… SELECT for that

INSERT INTO main (id, cols, faucet_name, owner, wallet, reward, timer, website) SELECT id, cols, faucet_name, owner, wallet, reward, timer, website FROM addsite WHERE addsite.id = <id to be copied>

Then remove the row from addsite in seperate DELETE query

Be sure to do all this in a transaction so you won’t end up in a situation where you’ve copied the row but could not delete the original. Either both queries should succeed, or both should fail.