在评论中显示img [英] displaying img in comment

查看:72
本文介绍了在评论中显示img的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨frnds,



在下面的代码中显示注释框但是它只显示文本.. hw以显示img以及相同格式的文本。 ...

 mysql_connect(localhost,root,); 
mysql_select_db(cmtdb);
error_reporting(E_ALL ^ E_NOTICE);
$ notify =;
$ name = $ _ POST ['name'];
$ comment = $ _ POST ['comment'];
$ submit = $ _ POST ['submit'];
if(isset($ _ POST ['notify_box'])){$ notify = $ _POST ['notify_box']; }
$ dbLink = mysql_connect(localhost,root,);
mysql_query(SET character_set_client = utf8,$ dbLink);
mysql_query(SET character_set_connection = utf8,$ dbLink);

if($ submit)
{
if($ name&& $ comment)
{
$ insert = mysql_query(INSERT INTO comment (姓名,评论)VALUES('$ name','$ comment'));
}
其他
{
echo请填写所有字段;
}
}

$ dbLink = mysql_connect(localhost,root,);
mysql_query(SET character_set_results = utf8,$ dbLink);
mb_language('uni');
mb_internal_encoding('UTF-8');

$ sql =SELECT * FROM comment;
$ getquery = mysql_query($ sql);
?>
< html >
< head >
meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< title > 评论框< / title >
< style 类型 = text / css < span class =code-keyword>>
body { margin auto 48px; }
< / 样式 >
< ; head >
< body >
< div >
< table id = commentTable >
< colgroup >
< col width = 25% / >
< col < span class =code-attribute> width = 75% / >
< / colgroup >
< thead >
< tr >
< th > 名称< / th >
< th > 评论< / th >
< / tr >
< ; / head >
< body >
while($ row = mysql_fetch_array($ getquery)){
echo'< td > '。 $ row ['name']。 '< / td > ' ;
echo'< td > '。 $ row ['comment']。 '< / td > ' ;
}
?>
< / body >
< / thead > < / table >
< / div >
< 表格 action = comment.php 方法 = POST >
< colgroup >
< col widht = 25% style = vertical-align:top; / >
< col < span class =code-attribute> widht = 75% 样式 = vertical-align:top; / >
< / colgroup >
< 表格 >
< tr >
< td > < label = < span class =code-keyword> name
> 名称< / label > < / td >
< td > < input 类型 = text 名称 = 名称 / > < / td >
&l t; / tr >
< tr >
< td > < label for = 评论 > 评论: < / label > < / td >
< td > < textarea 名称 = 注释 = 10 cols = 50 > < / textarea > < / td >
< / tr >
< tr > < td colspan = 2 > ; < 输入 类型 = 提交 名称 = 提交 value = 评论 > < / td > < / tr >
< / table >
< / form >
< / body >
< span class =code-keyword>< / html >

解决方案

notify =;


name =


_POST [ '名称'];

hi frnds,

in below code it ill display comment box but it display only text.. hw to display img as well with the text in same format....

mysql_connect("localhost","root","");
mysql_select_db("cmtdb");
error_reporting(E_ALL ^ E_NOTICE);
$notify = "";
$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }
$dbLink = mysql_connect("localhost", "root", "");
    mysql_query("SET character_set_client=utf8", $dbLink);
    mysql_query("SET character_set_connection=utf8", $dbLink);
 
if($submit)
{
    if($name&&$comment)
    {
        $insert=mysql_query("INSERT INTO comment (name,comment) VALUES ('$name','$comment') ");
    }
    else
    {
        echo "please fill out all fields";
    }
}
 
$dbLink = mysql_connect("localhost", "root", "");
mysql_query("SET character_set_results=utf8", $dbLink);
mb_language('uni');
mb_internal_encoding('UTF-8');
 
$sql = "SELECT * FROM comment";
$getquery = mysql_query($sql);
?>
<html>
<head>
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Comment box</title>
<style type="text/css">
body { margin: auto 48px; }
</style>
<head>
<body>
    <div>
        <table id="commentTable">
            <colgroup>
                <col width="25%" />
                <col width="75%" />
            </colgroup>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Comment</th>
                </tr>
            </head>
            <body>
while($row = mysql_fetch_array($getquery)) {
    echo '<td>' . $row['name'] . '</td>';
    echo '<td>' . $row['comment'] . '</td>';
}
?>
            </body>
        </thead></table>
    </div>
    <form action="comment.php" method="POST">
        <colgroup>
            <col widht="25%" style="vertical-align:top;" />
            <col widht="75%" style="vertical-align:top;" />
        </colgroup>
        <table>
            <tr>
                <td><label for="name">Name</label></td>
                <td><input type="text" name="name"/></td>
            </tr>
            <tr>
                <td><label for="comment">Comment:</label></td>
                <td><textarea name="comment" rows="10" cols="50"></textarea></td>
            </tr>
            <tr><td colspan="2"><input type="submit" name="submit" value="Comment"></td></tr>
        </table>
    </form>
</body>
</html>

解决方案

notify = "";


name=


_POST['name'];


这篇关于在评论中显示img的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆