The first file, updatebyitem.php functions as a database search for a specific item. Next, updatebyitemprocess.php finds the results of the search and outputs them in a table with checkboxes. I made it so that you can select checkboxes and push the "Edit" button, which will take you to editselection.php that outputs the rows that were checked for editing in text areas. The next step for me is to take all of the new, edited information and update the mysql database. I have no idea how to do this next part because the amount of information that is being updated varies by the amount of checkboxes selected for editing in updatebyitemprocess.php.
Any help appreciated.
-Brandon
(Mysql and php programmer for 2 days)
*** FILE *** "updatebyitem.php"
Expand|Select|Wrap|Line Numbers
- <html>
- <title>Update By Item</title>
- <?php
- include("menu.php");
- include("sqlconnect.php");
- ?>
- <body>
- <p align="center">
- Search Inventory by <b>ITEM</b> for update:
- <form align="center" name="updatebyitem" id="updatebyitem" action="updatebyitemprocess.php" method="post">
- <input name="item" type="text">
- <input type="submit" value="Search">
- <br /><br />
- <INPUT TYPE="BUTTON" VALUE="<-- Back to Menu" ONCLICK="window.location.href='http://localhost/Inventory/updatemenu.php'">
- </form>
- </p>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- <html>
- <title>Search By Item Results</title>
- <?php
- include("menu.php");
- include("sqlconnect.php");
- ?>
- <body>
- <p align='center'><INPUT TYPE="BUTTON" VALUE="<-- Back to Search" ONCLICK="window.location.href='http://localhost/Inventory/updatebyitem.php'">
- <form name="updateselect" action="editselection.php" method="post">
- <?php
- $item = $_POST['item'];
- echo "The item you entered was: <b>" . $item . "</b>";
- echo "<table border='1' class='dataTable' cellspacing='0'>
- <thead>
- <tr><th>Selection</th>
- <th>Brand</th>
- <th>Supplier</th>
- <th>Item Number</th>
- <th>Item Description</th>
- <th>Secondary Description</th>
- <th>Size & Volume</th>
- <th>Color</th>
- <th>Whole Cost</th>
- <th>Retail Cost</th>
- <th>Ideal Quantity</th>
- <th>Present Quantity</th>
- <th>Retail In Inventory</th>
- <th>Quantity To Order</th>
- <th>Item</th></tr>
- </thead><tbody>";
- $result = mysql_query("SELECT * FROM inventory WHERE Item LIKE '%$item'");
- while ($row = mysql_fetch_array($result))
- {
- $row_id = $row['id'];
- echo "<tr><td><input name='itemselect[]' type='checkbox' value='" . $row_id . "'></td>";
- echo "<td>";
- echo $row['Brand'];
- echo "</td>";
- echo "<td>";
- echo $row['Supplier'];
- echo "</td>";
- echo "<td>";
- echo $row['ItemNumber'];
- echo "</td>";
- echo "<td>";
- echo $row['ItemDescription'];
- echo "</td>";
- echo "<td>";
- echo $row['TypeSizeVolume'];
- echo "</td>";
- echo "<td>";
- echo $row['SizeVolume'];
- echo "</td>";
- echo "<td>";
- echo $row['Color'];
- echo "</td>";
- echo "<td>";
- echo $row['WholeSaleCost'];
- echo "</td>";
- echo "<td>";
- echo $row['RetailCost'];
- echo "</td>";
- echo "<td>";
- echo $row['IdealQuantity'];
- echo "</td>";
- echo "<td>";
- echo $row['QuaninInventory'];
- echo "</td>";
- echo "<td>";
- echo $row['RetailDollarsInInventory'];
- echo "</td>";
- echo "<td>";
- echo $row['QuantityToOrder'];
- echo "</td>";
- echo "<td>";
- echo $row['Item'];
- echo "</td>";
- echo "</tr>";
- }
- ?>
- </tbody>
- </table>
- <br /><br />
- <input type="submit" value="Edit">
- </form>
- </p>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- <html>
- <title>Edit Selection</title>
- <body>
- <?php
- include("menu.php");
- include("sqlconnect.php");
- ?>
- <p align="center"><b>Make your updates --</b></p>
- <style>
- textarea {resize: none;}
- </style>
- <form name="edits" action="updatecomplete.php" method="post">
- <?php
- //$row_id = $_POST['itemselect'];
- $row_id = array();
- foreach ($_POST['itemselect'] as $entry)
- {
- $row_id[] = $entry;
- $result = mysql_query("SELECT * FROM inventory WHERE id='" . $entry . "'");
- while ($row = mysql_fetch_array($result))
- {
- echo "Item Selected: <b>" . $row['Item'] . "</b><br/><br />";
- echo "<b>Brand: <b><br /><textarea name='brandedit'>" . $row['Brand'] . "</textarea><br /><br />";
- echo "<b>Supplier: </b><br /><textarea name='supplieredit'>" . $row['Supplier'] . "</textarea><br /><br />";
- echo "<b>Item Number: </b><br /><textarea name='itemnumberedit'>" . $row['ItemNumber'] . "</textarea><br /><br />";
- echo "<b>Item Description: </b><br /><textarea name='itemdescriptionedit'>" . $row['ItemDescription'] . "</textarea><br /><br />";
- echo "<b>Secondary Description: </b><br /><textarea name='secondarydescriptionedit'>" . $row['TypeSizeVolume'] . "</textarea><br /><br />";
- echo "<b>Size & Volume: </b><br /><textarea name='sizevolumeedit'>" . $row['SizeVolume'] . "</textarea><br /><br />";
- echo "<b>Color: </b><br /><textarea name='coloredit'>" . $row['Color'] . "</textarea><br /><br />";
- echo "<b>Wholesale Cost: </b><br /><textarea name='wholecostedit'>" . $row['WholeSaleCost'] . "</textarea><br /><br />";
- echo "<b>Retail Cost: </b><br /><textarea name='retailcostedit'>" . $row['RetailCost'] . "</textarea><br /><br />";
- echo "<b>Ideal Quantity: </b><br /><textarea name='idealquantityedit'>" . $row['IdealQuantity'] . "</textarea><br /><br />";
- echo "<b>Present Quantity: </b><br /><textarea name='presentquantityedit'>" . $row['QuaninInventory'] . "</textarea><br /><br />";
- echo "<b>Retail $ In Inventory: </b><br /><textarea readonly='readonly' name='retailininventoryedit'>" . $row['RetailInInventory'] . "</textarea><br /><br />";
- echo "<b>Quantity to Order: </b><br /><textarea readonly='readonly' name='quantitytoorderedit'>" . $row['QuantityToOrder'] . "</textarea><br /><br />";
- echo "<b>Item: </b><br /><textarea name='itemedit'>" . $row['Item'] . "</textarea><br /><br /><br />";
- echo "<hr size='10' align='center' color='#FF0000'>";
- }
- }
- ?>
- <br />
- <input type="submit" value="Submit Updates">
- </form>
- </body>
- </html>