mysqli 확장 프로그램을 사용하여 MySQL 데이터베이스에 연결하는 PHP 스크립트가있어서 사용자 이름이나 ID를 기반으로 블로그 게시물을 검색합니다.where 절에 'chenzhen'컬럼이 없습니다.
는 사용자 정보를 가지고 Profiles
, BlogPosts
및 BlogCategory
라고 가져옵니다 표 : I는 다음과 같이 표시됩니다 내가 함께 필요한 정보를 집계하기 위해 다른 테이블을 형성 조인 사용 BlogSearch
라는 VIEW를 생성 Unknown column 'chenzhen' in 'where clause'
PHP 코드 나는 아래 사용하고 있습니다 : 나는 검색
매번 나는 오류가
require 'database.php';
$query = "SELECT * FROM BlogSearch";
echo <<<EOF
<form method='post' action='' style="padding: 30px 0;">
<table cellspacing="0" border="0" style="float: left;">
<tr>
<td>Search Blog Posts by Username/ID</td>
<td><input type="text" id="search" name="search" style="width: 300px;"/></td>
<td><input type="submit" id="submit_button" value="Search" name="submit_button" style="float: right;" /></td>
</tr>
</table>
</form>
EOF;
if(isset($_POST['submit_button']))
{
$search_term = $_POST['search'];
$query = $query . " WHERE `NickName` LIKE '%$search_term%' OR ID = $search_term ";
// run the query and store the results in the $result variable.
$result = $mysqli->query($query) or die(mysqli_error($mysqli));
}
if ($result) {
// create a new form and then put the results
// into a table.
echo "<form method='post' action='delete.php' style='clear: both;'>";
echo "<table cellspacing='0' cellpadding='15'>
<th width='5%'>
<input type='checkbox' id='allcb' onclick='checkAll(this)' name='allcb' />Check All
</th>
<th width='10%'>User</th>
<th width='85%'>Blog Post Title</th>
";
while ($row = $result->fetch_object()) {
$title = substr($row->PostCaption,0,50);
$id = $row->PostID;
$user = $row->NickName;
//put each record into a new table row with a checkbox
echo "<tr>
<td><input type='checkbox' name='checkbox[]' id='checkbox[]' value=$id />
<td>$user</td>
<td>$title</td>
</tr>";
}
// when the loop is complete, close off the list.
echo "</table><p><input id='delete' type='submit' class='button' name='delete' value='Delete Selected Items'/></p></form>";
}
왜 사용자 이름이 열인지 식별 할 수 없습니다. 누구든지이 문제를 해결할 올바른 방향으로 나를 가리킬 수 있습니까?
미리 감사드립니다.
매우 간단하지만 아직 나는 빠졌습니다. 비록 내가 그 많은 방법을 사용해도 많은 변형을 시도했지만, 지금까지는 작동하지 않았습니다. 고마워 많은 작품! – Tower
사이드 노트 질문에 대한 질문이나 대답이 없으므로 ... 테이블 열 유형이 문자열 유형이면 열 유형이 int 유형이 아닌 경우 항상 '1'과 같은 qoutes를 사용하십시오. MySQL은 convert를 사용하여 데이터 유형을 형 변환합니다 여분의 오버 헤드를 유발하거나 경우에 따라 쓸모없는 색인을 생성 할 수 있습니다. –