开发者

mysql query only returning a single row

the following mysql query is only returning a single row when it should be returning 4.

$query = "SELECT * FROM questions";
    $result = mysql_query($query) or die("ERROR: $query.".mysql_error());
    // if records are present
    if (mysql_num_rows($result) > 0) {
    while ( $row = mysql_fetch_object($result) ){

    // get question 开发者_JAVA技巧ID and title
        $qid = $row->qid;
        echo '<div id=ques>';
        echo '<h2>'.$row->qtitle .'</h2>';
        echo '</div>';

        print_r ($row);

the print_r function displays this:

stdClass Object ( [qtitle] => dummy text here [qid] => 1 )


mysql_fetch_*() only pulls a single row at a time. Without seeing the rest of the loop it's impossible to tell if something else is going on down there.


You don't have closing brackets for while-loop and if

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜