2017-11-19 7 views
-2

내가 DB에 요청이 있습니다

$str = "SELECT name FROM `student_info` WHERE code='$code'"; 
$name = $link->query($str) or die(mysqli_error($link)); 

$ 이름는 반환하지 않습니다 아무것도

this is a structure of a student_info table

제발 도와주세요!

+1

을보십시오. 관련 코드를 게시하거나 오류를 확인하십시오 –

+0

* "도와주세요!"* - 어떻게 변수가 무엇인지, 그 값을 추측 할 수 있습니까? 안 그럴거야. –

+0

'var_dump ($ name)'은 무엇을 보여줍니까? – ceejayoz

답변

0

충분 코드는 여기이없는이

$sql = "SELECT name FROM student_info WHERE code='$code'"; 
$result = $conn->query($sql); 

if ($result->num_rows > 0) { 
    $row = $result->fetch_assoc(); 
    $name = $row["name"]; 
    }