0

我正在尝试通过此单选按钮回显或打印查询结果:

<input type="radio" name="Query" value="SELECT employees.name FROM employees, department WHERE employees.department_deptID=department.deptID AND department.departName="Information Technology""> List all employees in a particular department (Information Technology).<br />

我目前使用的代码是这样的:

if ($_POST['submit'] == "submit" && isset($_POST['Query'])){
$query = $_POST['Query'];
$result = mysql_query($query);
print $query;
while($row = mysql_fetch_assoc($result)){
    foreach($row as $cname => $cvalue){
        print "$cname: $cvalue\t";
    }
    print "\r\n";
}
    }

除了一些其他单选按钮,我还有一个提交按钮来启动操作:

<input type="submit" name="submit" value="submit">

提前感谢您的帮助。

4

1 回答 1

0

尝试以下块:

<input type="radio" name="Query" value="SELECT employees.name FROM employees, department WHERE employees.department_deptID=department.deptID AND department.departName='Information Technology'"> List all employees in a particular department (Information Technology).<br />

我已将at"替换'department.departName='Information Technology'

注意:这整个逻辑在我看来是个坏主意。您正在从浏览器传递查询,这会导致高风险。同时使用 mysqli_* 函数并停止使用 mysql_* 函数

于 2013-11-08T03:17:05.003 回答