Specifications
// most of the form is in plain HTML with some
// optional PHP bits throughout
?>
<form method=post
action=”<?=$edit?”edit_book.php”:”insert_book.php”;?>”>
<table border=0>
<tr>
<td>ISBN:</td>
<td><input type=text name=isbn
value=”<?=$edit?$book[“isbn”]:””; ?>”></td>
</tr>
<tr>
<td>Book Title:</td>
<td><input type=text name=title
value=”<?=$edit?$book[“title”]:””; ?>”></td>
</tr>
<tr>
<td>Book Author:</td>
<td><input type=text name=author
value=”<?=$edit?$book[“author”]:””; ?>”></td>
</tr>
<tr>
<td>Category:</td>
<td><select name=catid>
<?
// list of possible categories comes from database
$cat_array=get_categories();
foreach ($cat_array as $thiscat)
{
echo “<option value=\””;
echo $thiscat[“catid”];
echo “\””;
// if existing book, put in current catgory
if ($edit && $thiscat[“catid”] == $book[“catid”])
echo “ selected”;
echo “>”;
echo $thiscat[“catname”];
echo “\n”;
}
?>
</select>
</td>
</tr>
<tr>
Building Practical PHP and MySQL Projects
P
ART V
582
LISTING 25.19 Continued
31 7842 CH25 3/6/01 3:39 PM Page 582










