【问题标题】:PHP search Using multiple Criteria submitted from a formPHP搜索使用从表单提交的多个条件
【发布时间】:2017-10-17 17:31:48
【问题描述】:

我得到的错误是无法发出不同步的数据库查询命令。来自搜索表单的参数,我想通过输入所有要搜索的字段或单个字段进行搜索。

$query = "SELECT * FROM student WHERE idStudent = ? AND Student_Fname = ? AND Student_Sname = ? AND Program_idProgram = ? AND Class_idClass = ?";

    $stmt = mysqli_prepare($dbc, $query);

    mysqli_stmt_bind_param($stmt, 'sssss', $idStudent,
                           $Student_Fname, $Student_Sname, $Program_idProgram, $Class_idClass);

    mysqli_stmt_execute($stmt);

    $result = @mysqli_query($dbc, $query);

    if($result){  // display results here} 

【问题讨论】:

标签: php search


【解决方案1】:

尝试如下:

$query = "SELECT * FROM student WHERE idStudent = ? AND Student_Fname = ? AND Student_Sname = ? AND Program_idProgram = ? AND Class_idClass = ?";
 if ($stmt = $mysqli->prepare($query)) 
 {  
         $stmt>bind_param("sssss",$idStudent,$Student_Fname,$Student_Sname,$Program_idProgram, $Class_idClass);
         $stmt->execute();
 }
else
{
    /* error handling*/
}

更多信息请查看this

【讨论】:

  • 这是记得点击你忘记的勾号来接受答案。 @Zweli Golowa
猜你喜欢
  • 2022-11-22
  • 1970-01-01
  • 2015-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多