【发布时间】:2010-02-04 20:21:34
【问题描述】:
我正在制作分类广告网站... 我有这 6 张桌子: 每个类别都有子类别(或选项),您可以在下面看到。
假设用户想要发布分类,并且已将所有信息输入到必要的表单中,而我正处于必须创建 PHP 代码以将数据实际插入数据库的阶段。
我在想这样的事情:
mysql_query("INSERT INTO classifieds (classified_id, ad_id, poster_id, cat_id, area_id, headline, description) VALUES ($classified_id, '$ad_id', $poster_id, $cat_id, $area_id, '$headline', '$description')");
但我不知道从这里到哪里...
我认为海报表不应该是这样的,因为我应该如何确定poster_id 应该是什么?还是应该将其设置为auto-increment?
记住这一点,发帖人可能不会登录或任何事情,所以如果你明白我的意思,一个人拥有多个 poster_table 记录是没有问题的。
classified_id 是 PHP 生成的随机唯一值,因此始终是唯一的。
请指导我!我不知道如何正确地将表格链接在一起。
如果你有任何 Q 告诉我,我会更新这个 Q!
category table:
cat_id (PK)
cat_name
category_options table:
option_id (PK)
cat_id (FK)
option_name
option_values table:
value_id (PK)
option_id (FK)
value
classifieds table:
classified_id (PK)
ad_id (VARCHAR) something like "Bmw330ci_28238239832" which will appear in URL
poster_id (FK)
cat_id (FK)
area_id (FK)
headline
description
price
etc....
posters table:
poster_id (PK)
name
email
tel
password
area table:
area_id (PK)
area
community
【问题讨论】: