phpanon Posted March 6, 2008 Share Posted March 6, 2008 Hello everyone, I have a simple internal ordering system. Every order needs to be approved by the manager before it can be submitted. What idealy I want to happen is that, if for some reason the manager rejects an order then when he changes the dropdown menu to 'Reject' a text box appears where he can write the reasons for rejection which can then be writen to the database with the rest of the information into the 'comments' field. Thanking you kindly in advance Here is my code <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } require "connect.php"; $orderID = $_GET['orderID']; $query = "SELECT * FROM orders o, productorder p WHERE o.orderID = p.orderID AND p.status = 'Awaiting Approval' AND o.orderID = ".$orderID; $result = mysql_query($query, $connection) or die ("Unable to perform query $query"); $row= mysql_fetch_array($result); $query3 = "SELECT * FROM orders WHERE orderID = ".$orderID; $result3 = mysql_query($query3, $connection) or die ("Unable to perform query $query3"); $row3= mysql_fetch_array($result3); ?> <body> <div id="OrdersBasketTable"> <table border="0" width="100%"> <hr /> <tr> <th width="100">Order Number</th> </tr> <tr><td align="center"><h2><strong><?php echo $row['orderID']?></strong></h2></td> <td> <table border="0"width="100%"> <tr> <th width="30%" align="left">Product</th> <th width="10%" align="left">Price</th> <th width="10%" align="left">Quantity</th> <th width="14%" align="left">Date</th> <th width="25%" align="left">User</th> <th width="13%" align="left">Total</th> </tr> <tr> <?php $query2 = "SELECT * FROM orders o, productorder e, product p WHERE o.orderID = e.orderID AND p.URN = e.URN AND e.status = 'Awaiting Approval' AND o.orderID = '".$row['orderID']."'"; $result2 = mysql_query ($query2, $connection) or die ("Unable to perform query<br>$query2"); while($row2=mysql_fetch_array($result2)) { ?> <tr> <td><?php echo $row2['productName']?></td> <td>£<?php echo $row2['price']?></td> <td align="center"><?php echo $row2['quantity']?></td> <td><?php echo $row2['date']?></td> <td><?php echo $_SESSION['fName']?> <?php echo $_SESSION['sName']?></td> <?php $total = $row2['quantity'] * $row2['price']; ?> <td>£<?php echo $total ?></td> <?php $total2 = $total2 + $total ?> </tr> <?php } ?> </td> </tr> <td></td> <td></td> <td></td> <td></td> <td><strong>Total</strong></td> <td>£<?php echo $total2 ?></td> <td></td> </table> </table> </td> </table> <form action="OrderApprovalQuery.php" method="get"> <table width ="100%" border="0"> <tr> <td>Status:</td> <td><select name="status"> <option>Awaiting Approval</option> <option>Complete</option> <option>Reject</option> </select></td> <td> </td> </tr> <tr> <td><input name="orderID" type="hidden" value="<?php echo $row3['orderID']?>" /></td> <td> </td> <td> </td> </tr> <tr> <td width="20%"> </td> <td width="22%"><input name="Save" type="submit" value="Update" /></td> <td width="58%"> </td> </tr> </table> </form> </div> </body> <?php require "connect.php"; $orderID = $_GET['orderID']; $status = $_GET['status']; $query = "UPDATE productorder SET status = '".$status."', apprDate = '".date("d-M-Y")."' WHERE orderID = ".$orderID; $result = @mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); header("Location: pendingOrders.php"); exit(); ?> Link to comment https://forums.phpfreaks.com/topic/94677-textbox-to-appear/ Share on other sites More sharing options...
priti Posted March 6, 2008 Share Posted March 6, 2008 Hi, Near </select></td> <td> </td>---- create a div with style hidden and on dropdown of status and its event onchange create a js function which checks wether it is status=='Rejected' then show you div and do something like div.innerHTML='<input type="comment" value="your message">'; so when you will submi tyour form you will be able to read this comment text box. hope it help you !! Link to comment https://forums.phpfreaks.com/topic/94677-textbox-to-appear/#findComment-484796 Share on other sites More sharing options...
phpanon Posted March 6, 2008 Author Share Posted March 6, 2008 Hi, Thanks... Does it have to be in java script or is there a way of doing it in php?? Just not very good at js, im struggling as it is in php Link to comment https://forums.phpfreaks.com/topic/94677-textbox-to-appear/#findComment-484874 Share on other sites More sharing options...
phpanon Posted March 6, 2008 Author Share Posted March 6, 2008 can anyone else expand on this? Link to comment https://forums.phpfreaks.com/topic/94677-textbox-to-appear/#findComment-484903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.