/    Sign up×
Community /Pin to ProfileBookmark

Approve function for Admin User

Hey guys. I’m just wondering behind the logic of approve function (e.g. if User request an item, admin will see in hes/her table the request item and then the admin will click “approve” button to confirm);

below are my script:

HTML:
`<?php`
`define(‘DBHOST’,’localhost’);`
`define(‘DBNAME’,’db_aacadmin’);`
`define(‘DBUSER’,’root’);`
`define(‘DBPASS’,”);`

`try`
`{`
`$conn = new PDO(“mysql:host=”.DBHOST.”;charset=utf8mb4;dbname=”.DBNAME, DBUSER,DBPASS);`
`$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);`

`$qry = “SELECT * FROM tbl_woplnrfrm”;`
`$stmt = $conn->prepare($qry);`
`$stmt->execute();`
`$result = $stmt->fetchAll(PDO::FETCH_ASSOC);`
`}`
`catch(PDOException $e)`
`{`
`die(“Error Connection”.$e->getMessage());`
`}`
`?>`
`<div class=”box-body” style=”max-width: 5000px; overflow: auto;”>
<table id=”example2″ class=”table table-bordered table-striped”>
<thead>
<tr>
<th>Item #</th>
<th>Date</th>
<th>WO #</th>
<th>Item Description</th>
<th>P/N / Specs</th>
<th>Qty</th>
<th>U/M</th>
<th>Purpose</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
foreach($result as $value)
{
echo ‘<tr id=”plnr_id_’ .$value[‘plnr_id’]. ‘”data-id=”‘ .$value[‘plnr_id’]. ‘”>
<td>’ .$value[‘plnr_id’]. ‘</td>
<td>’ .$value[‘plnr_dte’]. ‘</td>
<td>’ .$value[‘plnr_wocde’]. ‘</td>
<td>’ .$value[‘plnr_itmdesc’]. ‘</td>
<td>’ .$value[‘plnr_pnspecs’]. ‘</td>
<td>’ .$value[‘plnr_qty’]. ‘</td>
<td>’ .$value[‘plnr_um’]. ‘</td>
<td>’ .$value[‘plnr_prpse’]. ‘</td>’;
echo “<td><a href=’#’ name=’approve’><i class=’fa fa-thumbs-up’> Approve</i></a>”; echo “&nbsp”; echo “&nbsp”;
echo “<a href=’#’><i class=’fa fa-eye’> View Attached File”;
}
?>
</tfoot>
</table>
</div>
<!– /.box-body –>
</div>
<!– /.box –>
</div>
<!– /.col –>
</div>
<!– /.row –>
</section>
<!– /.Left col –>
</div>
</div>`

————————————————————————————————————————–
can someone help me the logic if the admin will approve, it will return to the user that the item request has been approve. Thank you for the help guys!!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@fekpe_peterNov 15.2019 — The logic behind this will be creating a field eg: "status" with lets say a default value of "2" in your "items" table. At the admin's portal, fetch items with "status" 2 and create a link "confirm". When the admin clicks the confirm link, update the item's status from "2" to "1" with the help of the selected item's id. From there, send a confirmation message that item has been approved.

In case you want to fetch all approved items, use the "where" clause, in this case "...WHERE status = 1...".

i hope this helps you. thanks
×

Success!

Help @spdfrk24 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...