doudang4857 2011-07-11 22:13
浏览 151

使用相同的php表单添加/查看/编辑mysql条目

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.

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效