<?php
if(isset($_GET['search']))
{
$search_record = $_GET['search'];
$query = "SELECT * FROM semester_result,SUBJECT,std_reg WHERE semester_result.sub_id=subject.sub_id AND
semester_result.student_id = std_reg.student_id AND std_reg.roll_no='$search_record' ";
$run = mysqli_query($conn,$query);
if ($run->num_rows > 0)
{
while($row = mysqli_fetch_array($run))
{
$name = $row['fname'];
$lname = $row['lname'];
$sub=['subject_name'];
echo $sub_id=['mid_mrks'];
?>
当我回显$name
或$lname
时,它可以正常工作,但当我回显$sub
或$sub_id
时,它会显示以下错误:
注意:第49行的C:\ wamp \ www \ semester \ content \ result.php中的数组到字符串转换。
答案 0 :(得分:1)
该错误是由于将数组变量传递给echo()
函数而不是字符串。
在您的示例中更改:
$sub=['subject_name'];
为:
$sub=$row['subject_name'];
将解决问题。
答案 1 :(得分:1)
这个怎么样?
$name = $row['fname'];
$lname = $row['lname'];
$sub = $row['subject_name'];
echo $sub_id = $row['mid_mrks'];
我想你忘记了$row
['subject_name']