选择/加入查询帮助(下拉框?) [英] Select/Join query help (dropdown box?)

查看:62
本文介绍了选择/加入查询帮助(下拉框?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿大家。


我正在重写一个php内容管理系统(基于

phpNuke,但具体到我的网站)。我的第一个重大改变是尝试

来规范化Review部分数据库结构。我创建了一个

员工表,其中包含员工电子邮件地址和姓名(以及ID),以及带有评论文本的

评论表。评论表包含

一个''作者''字段,其值与Staff表对应。

当我显示评论时,我成功使用了内部联接链接

记录并显示相关

评论的正确作者姓名/电子邮件。


我现在的问题是编辑时评论。我原本有一个基本的

php页面,它只是简单地选择了值并将它们加载到一个表单中,

但我现在无法使用它。具体来说,在

评论的提交表单中,我创建了一个下拉框,其中加载了

Staff表中的值。存储评论时,它会在Review表中正确存储所选作者ID的值。

。我的问题是当

编辑评论时,我无法让php在

评论表中查找作者ID,然后在下拉列表中显示正确的作者姓名

来自Staff表格的特定评论。


有人可以帮忙吗?连接的MySQL手册也可以用

希腊语写成。


马特

Hey everyone.

I''m re-writing a php Content Management System (based loosely on
phpNuke but specific to my site). My first major change was attempting
to normalise the Review section database structure. I''ve created a
Staff table with staff email addresses and names (plus id), and a
Reviews table with the text of the reviews. The Reviews table contains
an ''author'' field with a value that corresponds to the Staff table.
When I display a review, I successfully used an Inner Join to link the
records and display the correct author name/email for the relevant
review.

My problem now is when editing the reviews. I originally had a basic
php page that simply selected the values and loaded them into a form,
but I can''t get this to work now. Specifically, In the Submit form for
Reviews, I created a dropdown box which loaded the values from the
Staff table. When storing a review, it correctly stores the value for
the selected Author''s ID in the Review table. My problem is when
editing the review, I cannot get php to lookup the author ID in the
Reviews table, then display in the dropdown the correct Author Name
from the Staff table for that specific review.

Could anyone help? The MySQL manual for joins may as well be written in
Greek.

Matt

推荐答案

发布你的sql和你的错误信息。

post your sql along with your error message.


这里是SQL:

Here''s the SQL:


query =" SELECT Band_Name,Record_Name,Review,Staff_Name,Staff_id,

得分,Cover_Image,Record_Label,Band_Site_URL

FROM review_test INNER JOIN工作人员ON Reviewer_Name = staff.Staff_id

WHERE id =''
query = "SELECT Band_Name, Record_Name, Review, Staff_Name, Staff_id,
Score, Cover_Image, Record_Label, Band_Site_URL
FROM review_test INNER JOIN staff ON Reviewer_Name = staff.Staff_id
WHERE id=''


这篇关于选择/加入查询帮助(下拉框?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆