<form id="newItemDetails" method="post" action="dbentry.php"> Enter Item details: <table > <tr> <td>Name</td> <td><input type="text" name="Name" required></td> </tr> <tr> <td>Description</td> <td><input type="text" name="Description" required></td> </tr> <tr> <td>Brand</td> <td> <select name="Brand"><?php echo genBrand(); ?> </select> </td> </tr> <tr> <td>Price</td> <td><input type="text" name="Price" required></td> </tr> <tr> <td>Category</td> <td> <select name="Category" id='itemType'> <option value="HDD">Hard Disk Drive</option> <option value="Motherboard">Motherboard</option> <option value="Processor">Processor</option>
function getItemDetails($query) { dbconnect(); $result = execute($query); $string = ""; $row = mysql_fetch_assoc($result); $fields = array_keys($row); foreach ($fields as $detail) { if ($detail == "Brand") { $string .= "<tr><td>" . $detail . "</td><td><select name=" . $detail . ">"; $string .= genBrand(); $string .= "</td></tr>\n"; } else { $string .= "<tr><td>" . $detail . "</td><td><input type='text' value='" . $row[$detail] . "' class='itemDet' name='" . $detail . "' required></td></tr>\n"; } } return $string; }