Well, doing a beginner project. I've 100% finished with adding items to the DB. However, having stuck trying to use the "search" button to retrieve the DB list, as well updating errors.
Objective, input last name, click on search, and find the results based on the last name input. Here's what I have so far.
<?php include '../view/header.php'; ?> <div id="main"> <h1>Customer Search</h1> <div id="content"> <!-- display a table of products --> <form method="post" action="index.php" id="search_form"> <label>Last Name:</label> <input type="text" name="lastName"> <input type="submit" value="Search"> </form> <table> <tr> <th>last Name</th> <th>email</th> <th class="right">city</th> <th>phone</th> <th> </th> </tr> <?php foreach ($customers as $customer) : ?> <tr> <td><?php echo $customer['lastName']; ?></td> <td><?php echo $customer['email']; ?></td> <td class="right"><?php echo $customer['city']; ?></td> <td><?php echo $customer['phone']; ?></td> <td><form action="." method="post"> <input type="hidden" name="action" value="update_customer" /> <input type="hidden" name="customerID" value="<?php echo $customer['customerID']; ?>" /> <input type="submit" value="Select" /> </form></td> </tr> <?php endforeach; ?> </table> </div> </div> <?php include '../view/footer.php'; ?>
Line 1-14 has it's own php, the "customer_list.php" where it just shows the search bar. after clicking on it, it gets to my search.php. that's where I get errors. Undefined variable: customers line 25. And Invalid argument supplied for foreach()
Anyhelp is appreciated to the right direction. Just need guidance to get to the right step. I may have to tweak my index.php/customer_db.php.