I need some help with a PHP script. I’m trying to get the item variable to change when the J variable increments. Instead, the item variable is staying the same while the J variable works just fine. Any advice would be great.
[php]
<?php //inventory ID numbers $cleat = "id1"; $pants = "id2"; $jerseys = "id3"; $hat = "id4"; $glove = "id5"; $bat = "id6"; $helmet = "id7"; $penant = "id8"; //inventory $cleatinv = "12"; $pantsinv = "7"; $jerseysinv = "6"; $hatinv = "5"; $gloveinv = "4"; $batinv = "3"; $helmetinv = "2"; $penantinv = "1"; define ("LOWESTID", 1); define ("HIGHESTID", 8); $_POST["lower"]; $_POST["upper"]; //check for valid numbers from the input form // Check for valid numbers Thank you Gary for the great code for checking valid numbers the not or statement was brilliant if (!is_numeric($_POST["lower"]) || !is_numeric($_POST["upper"])) { echo "Enter valid numbers only."; } elseif ($_POST["lower"] > $_POST["upper"]) { echo "The lower number should be lowest and the upper number the highest."; } elseif ($_POST["lower"] < LOWESTID ) { echo "Lower number must be equal to or greater than " .LOWESTID; } elseif ($_POST["upper"] > HIGHESTID ) { echo "Upper number must not be greater than " .HIGHESTID; } $j = $_POST["lower"]; //Define $item while ($j <= $_POST["upper"]) { if ($_POST["lower"] = 1) { $item = $cleatinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } elseif ($_POST["lower"] = 2) { $item = $pantsinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } elseif ($_POST["lower"] = 3) { $item = $jerseyinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } elseif ($_POST["lower"] = 4) { $item = $hatinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } elseif ($_POST["lower"] = 5) { $item = $gloveinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } elseif ($_POST["lower"] = 6) { $item = $batinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } elseif ($_POST["lower"] = 7) { $item = $helmetinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } elseif ($_POST["lower"] = 8) { $item = $penantinv; echo "Item " .$j ." has " . $item ." left in stock." .""; $j++; } } ?>[/php]