doudi4137 2009-10-26 03:53
浏览 31

如何在php中编辑/管理多层条件数据

I have 4 tables in a mysql database that i need to add/edit/manage.

The difficulty, is that each one, is dependent on the one before it.

The way i have this setup on the user end, is you select an option from table 1. You are then presented with the options in table 2, that have the first option's ID in their row. Once you select option in table 2, you are taken to table 3, which generates its list where the rows contain the ID of your selection in table 2, and so on and so forth.

The problem is how to edit/manage this.

Obviously if you delete an option in table 1, all its subsequent child options will be invalid.

I just need an idea of how to manage a setup like this.

  • 写回答

2条回答 默认 最新

  • dousa2794 2009-10-26 04:27
    关注

    Multi-tiered data is most-often stored in with a parent:child relation field in a table.

    id  | name | parent_id
    ----------------------
    1   | Mom  | NULL
    2   | Son  | 1
    

    Write a recursive function/query to traverse the relationships and any updates/inserts/deletes should be relatively simple.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大