donglu3184 2015-02-21 06:45
浏览 28
已采纳

如何添加,编辑和删除数据库的逗号分隔值。

i have created one table called role and the fields are like (roleid,role,prohibitedprocess,prohibitedports) here roleid is unique. and i have a comma separated value for "prohibitedprocess" field .(ex: prohibitedprocess---> skype,teamviwer,notepad).

the problem is how to add and edit and delete that comma separated value of prohibitedprocess .is it possible ?

i have fetch the code form the data base .code is

      <?php 
                $sql = "SELECT roleid, prohibitedprocess, prohibitedports FROM role WHERE role='Basic'";
                $option='';
                $result = mysql_query($sql);
                while($row = mysql_fetch_assoc($result))
                {
                    $pro_proc = $row['prohibitedprocess'];
                    $lst = explode(",",$pro_proc);
                                        //Print in Option Box
                    foreach($lst as $exp)
                    {?> 
                        <tr>            
                        <td><?php echo $exp;?></td>
                        <td><a href="edit_form.php?id=$row[roleid]">Edit</a></td>
                        <td><a href="del_form.php?id=$row[roleid]">Delete</a></td></tr>
            <?php   
                    }
                }                       
                ?>

Design

How to do this please help me

  • 写回答

3条回答 默认 最新

  • dongqiao1151 2015-02-21 07:01
    关注

    You can edit the whole string . .

    I mean just using str_replace function

    e.g

    $string = "skype,teamviwer,notepad";
    
    $old_value = "skype";
    
    $new_value = "facebook";
    
    $new_string = str_replace($old_value,$new_value,$string);
    

    Then simply update this new string into database table. .

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序