I've written a PHP form to add entries into a MySQL database that looks like the first picture here. However, I also want to use the same form to view and edit information already in the database as shown in the second and third photos. What's the simplest way to do this?
2条回答 默认 最新
- dpwh11290 2011-07-11 22:19关注
Check to see if the value of the field is null in the database, if so, then don't fill in a value in the field:
<input type="text" name="title" value="<? if(!empty($row['title'])) echo $row['title']; ?>" />
For drop downs, make a table of values that would match the values in the drop down, then you can match your id if there is one and print something like this:
<select name="country"> <option value="85" <? if($row['country'] == 85) echo " selected"; ?> />
This is a rather broad answer for a rather broad question.
解决 无用评论 打赏 举报