ID 필드에 개별 게시물 (post-id : 1932 등)에 태그를 지정하려고하면 값은 항상 데이터베이스 값 대신 0으로 인쇄됩니다.PHP/MySQL 인쇄 0 내부 int 값
쿼리는 (링크를 클릭하여 생성 된) $ _REQUEST의 항목 변수를 사용합니다.
<?php
require_once 'connect.php';
$topic = $_REQUEST['topic'];
// Build the SELECT statement
$select_posts =
"SELECT p.topic, p.title, p.pic_id, p.snippet, p.content, p.author_id, p.date FROM posts p WHERE p.topic = '" . $topic . "' OR p.topic='Admin' ORDER BY p.date DESC";
// Run the Query
$result = mysql_query($select_posts);
?>
<?php
$post_count=0;
while ($post_count<10 && $posts = mysql_fetch_array($result)) {
$posts_row = sprintf(
'<entry>
<headline>%s</headline>
<pic><img class=inlinepic src=/Sustenance/assets/post-pics/%d.jpg></pic>
<snippet class=on id="%d snippet">%s</snippet>
<readmore id="readmore%d" class=on onclick=readmore("%d")>Read More</readmore>
<content id="%d" class="less">%s
<readmore class=on onclick=readless(%d)>Show Less</readmore>
</content>
<byline>
<by>by</by>
<author>%s</author>
</byline>
</entry>',
$posts['topic'], $posts['title'], $posts['pic_id'], $posts['post_id'], $posts['snippet'], $posts['post_id'], $posts['post_id'], $posts['post_id'], $posts['content'], $posts['post_id'], $posts['author_id']);
echo $posts_row;
$post_count++;
}
?>
는 내가 이상한 발견하는 것은 제대로 'pic_id'인쇄하고 올바른 촬영에 끌어하지만, 심지어는 $의 divId는에 pic_id를 다시 사용하려고 할 때 그것은 '아무튼 : 여기
내 코드입니다 일하지 마라. 나는 $ posts를 $ posts [ 'id']로 바꾸고, PHP Manual에있는 모든 다른 정수 타입 지정자를 사용하고 심지어 인라인 PHP를 사용해 보았습니다.구문 오류가 있습니까? 왜 인쇄가 0으로 유지됩니까?
편집 : 나는
요청 EDIT 2에 따라 쿼리를 게시 한 다음 $의 divId는 변수를 제거.
으로 작성하십시오. –
은 * $ division = $ posts [ 'post_id']가 아니어야합니다 * while 루프가 있습니까? –