Question: Can you please fix the code so it runs like this... does not need sql this is just a basic add or delete needs to

Can you please fix the code so it runs like this... does not need sql this is just a basic add or delete

needs to look like this

Can you please fix the code so it runs like

Source code for inventory.phpMy Inventory

My Inventory

$self = $_SERVER['PHP_SELF'];

// Check to see if this is the first time viewing the page // The hidSubmitFlag will not exist if this is the first time if(array_key_exists('hidSubmitFlag', $_POST)) { echo "

Welcome back!

"; // Look at the hidden submitFlag variable to determine what to do $submitFlag = $_POST['hidSubmitFlag']; // echo "DEBUG: hidSubmitFlag is: $submitFlag
"; //echo "DEBUG: hidSubmitFlag is type of: " . gettype($submitFlag) . "
"; // Get the array that was stored as a session variable $invenArray = unserialize(urldecode($_SESSION['serializedArray'])); switch($submitFlag) { case "01": addRecord( ); break;

case "99": deleteRecord( ); break;

default: displayInventory($invenArray); } } else { echo "

Welcome to the Inventory Page

"; // First time visitor? If so, create the array $invenArray = array( ); $invenArray[0][0] ="1111"; $invenArray[0][1] ="Rose"; $invenArray[0][2] ="1.95"; $invenArray[0][3] ="100"; $invenArray[1][0] ="2222"; $invenArray[1][1] ="Dandelion Tree"; $invenArray[1][2] ="2.95"; $invenArray[1][3] ="200";

$invenArray[2][0] ="3333"; $invenArray[2][1] ="Crabgrass Bush"; $invenArray[2][2] ="3.95"; $invenArray[2][3] ="300";

// Save this array as a serialized session variable $_SESSION['serializedArray'] = urlencode(serialize($invenArray)); } // echo "DEBUG: invenArray:"; // print_r($invenArray); // echo "
"; /* ========================================= Functions are alphabetical ========================================= */ function addRecord( ) { global $invenArray; // Add the new information into the array // items stacked for readability $invenArray[ ] = array($_POST['txtPartNo'], $_POST['txtDescr'], $_POST['txtPrice'], $_POST['txtQty']); // The sort will be on the first column (part number) so use this to re-order the displays sort($invenArray); // Save the updated array in its session variable $_SESSION['serializedArray'] = urlencode(serialize($invenArray)); } // end of addRecord( ) function deleteRecord( ) { global $invenArray; global $deleteMe; // Get the selected index from the lstItem $deleteMe = $_POST['lstItem']; // echo "DEBUG: \$deleteMe is: " . $_POST['lstItem'];

// Remove the selected index from the array unset($invenArray[$deleteMe]); // echo "

Record deleted

"; // Save the updated array in its session variable $_SESSION['serializedArray'] = urlencode(serialize($invenArray)); } // end of deleteRecord( ) function displayInventory( ) { global $invenArray; echo "";

// display the header echo "

"; echo ""; echo ""; echo ""; echo ""; echo "";

// Walk through each record or row foreach($invenArray as $record) { echo "

"; // for each column in the row foreach($record as $value) { echo ""; } echo ""; } // stop the table echo "
Part No.DescriptionPriceQty
$value
"; } // end of displayInventory( ) ?>

Plants You-nique

Here is our current inventory

Add an item






Select an item to delete
A Welcome to the Inventory Page Plants You-nique Here is our current inventory Part No. 1111 2222 3333 Description Rose Dandelion Tree Crabgrass Bush Price 1.95 2.95 3.95 Qty 100 200 300 Add an item Part Number: Description: The Deser Price: SUS2215 Quantity in Stock: Select an item to delete

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!