duanfei8149 2014-04-30 07:57
浏览 10

SQL字段作为使用PhP的HTML

I would like to use the contents of a field in an SQL table as HTML. The table field contains HTML.

TABLE NAME: "destination"
HTML code stored in column called: "post"
Table primary key: "destId"

My PhP code (inside PhP tags of course:

// Selects the post from destinations table
$sql = "SELECT post FROM `destination` WHERE destiD = 1;"; //SQL Query
$result = mysqli_query($con, $sql) or die(mysqli_error($con)); //run the query

echo $result; // Inserts HTML


Error received:

Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\xampp\htdocs\travel\including\destinations\1-London.php on line 6

Any help would be much appreciated.

  • 写回答

3条回答 默认 最新

  • donglin9068 2014-04-30 07:59
    关注

    $result is an array, you should try to convert it with a loop

    for($result as $x){
        echo $x;
    }
    
    评论

报告相同问题?