douchenbiao0916 2013-08-03 08:42
浏览 55
已采纳

php查询mysql文本

i'm having problems while querying for mysql "text" data.

here's my code:

$result_odg = mysqli_query($con,"SELECT * FROM agenda WHERE data = '" . $today . "' AND odg IS NOT NULL");
echo "<h4>ODG:</h4>";

if (mysqli_fetch_array($result_odg)) {
    $i = 1;
    echo "<table id=\"agenda_odg\">";
    while($row = mysqli_fetch_array($result_odg)) {
        if($i % 2 == 0)
            $cellID = "even";
        else
            $cellID = "odd";
        echo "<tr id=" . $cellID . "><td>" . $row['testo'] . "</td></tr>";
        $i == $i++;
    }
    echo "</table>";
} else {
    echo "No ODG";
}

the table have the following fields: id, data_ins, data, testo, odg, agenda, ok.

using any other name than "testo" in $row['testo'] (example $row['id']) will print out the text. is there any special query to do for "TEXT" type fields? maybe because it's too heavy and needs a particular array? can't find anything about this on the manual...

  • 写回答

2条回答 默认 最新

  • dongzhina7098 2013-08-03 08:50
    关注

    please use

    // no need to fetch the result for check (shorten runtime time)
    if ($result_odg) {
    
        while($row = mysqli_fetch_assoc($result_odg)) {
            // use $row['testo'] is possible
    
            // replace this too
            $i++;
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?