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 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料