Specifications
</TR>
<TR>
<TD ALIGN=CENTER><INPUT TYPE=FILE NAME=”html” SIZE=40></TD>
</TR>
<TR>
<TD ALIGN=CENTER>Picture</TD>
</TR>
<TR>
<TD ALIGN=CENTER><INPUT TYPE=FILE NAME=”picture” SIZE=40></TD>
</TR>
<?
if ($s[picture]) {
$size = getImageSize($s[picture]);
$width = $size[0];
$height = $size[1];
?>
<TR>
<TD ALIGN=CENTER>
<IMG SRC=”<? echo $s[picture];?>”
WIDTH=<? echo $width;?> HEIGHT=<? echo $height;?>>
</TD>
</TR>
<? } ?>
<TR>
<TD ALIGN=CENTER><INPUT TYPE=SUBMIT VALUE=”Submit”></TD>
</TR>
</TABLE>
</FORM>
The same script can be used whether adding or editing, and the action depends on whether
$story is set when the script is called.
if (isset($story))
$s = get_story_record($story);
The function get_story_record() is defined in db_fns.php and returns an array of all the
fields in the stories table for the specified story ID. If no story ID is passed in, $story will be
null and $s will not contain the array elements.
<INPUT SIZE=80 NAME=”headline” VALUE=”<? echo $s[headline];?>”>
Building Practical PHP and MySQL Projects
P
ART V
608
LISTING 26.6 Continued
32 7842 ch26 3/6/01 3:36 PM Page 608










