[英]Phpmyadmin SQL result doesn't give the proper result
I'm using PHPMyAdmin to manage my database, and I'm currently trying to use one for a project for school. 我正在使用PHPMyAdmin管理我的数据库,目前正在尝试使用一个用于学校的项目。
I'm using a TinyMCE text editor to make people add text. 我正在使用TinyMCE文本编辑器让人们添加文本。 This eventually get stored into the database with some <> attached.
最终,这会附加到<>并存储到数据库中。
When I want the user to look into his written review, he sees the following http://i.imgur.com/zp3kupn.png . 当我希望用户查看他的书面评论时,他会看到以下http://i.imgur.com/zp3kupn.png 。
I want the <p>
to be gone. 我希望
<p>
消失。 But it's right from the database. 但这是从数据库中得出的。
The code I'm using is the following: 我正在使用的代码如下:
}
else {
$code = $_POST['view_id'];
$sql = 'SELECT * FROM review WHERE `Reviewnr` = :code ';
$std = maakConnectie()->prepare($sql);
$std->bindValue (":code", $code, PDO::PARAM_STR);
$std->execute();
$result = $std->fetchAll(PDO::FETCH_ASSOC);
if(count($result) ==0) {
echo 'U heef geen review geschreven, <a href="schrijven_review.php">Klik hier </a> om een review te schrijven';
} else {
echo '<table>';
foreach ($result as $index => $value){
$code = $value['Reviewnr'];
echo '
<tr>
<td class="bold"> Review nr: </td>
<td> '.$value['Reviewnr'].'</td>
</tr>
<tr>
<td class="bold"> Laatst gewijzigd op: </td>
<td> '.$value['Laatste_wijzigingsdatum'].'</td>
</tr>
<tr>
<td class="bold"> Geplaatst op:</td>
<td>'. $value['Plaatsings_datum'].'</td>
</tr>
<tr>
<td class="bold"> Titel: </td>
<td>'. $value['Titel'].'</td>
</tr>
</table>
<table>
<tr>
<td class="bold"> Review: </td>
</tr>
<tr>
<td> <textarea readonly style="resize: none" rows="10" cols="50" name="review">'. $value['Inhoud'].'</textarea></td>
</tr>
';
}
echo '</table>
The textarea where it's all about but I figured I post something more so you know it's print from the database. 关于textarea的所有内容,但我认为我还会发布更多内容,因此您知道它是从数据库打印出来的。
Please help me get rid of the "< p>" in the text area. 请帮助我摆脱文本区域中的“ <p>”。
You can use strip_tags( )
( http://us1.php.net/strip_tags ) to remove HTML tags from a string. 您可以使用
strip_tags( )
( http://us1.php.net/strip_tags )从字符串中删除HTML标签。
I think the best solution for your scenario would be to simply output the HTML outside of the textarea. 我认为针对您的方案的最佳解决方案是仅在textarea之外输出HTML。 Doing that will display the "styled" text/rendered HTML that the user created in TinyMCE.
这样做将显示用户在TinyMCE中创建的“样式化”文本/渲染的HTML。
Here's my suggestion based on your code: 这是根据您的代码提出的建议:
}
else {
$code = $_POST['view_id'];
$sql = 'SELECT * FROM review WHERE `Reviewnr` = :code ';
$std = maakConnectie()->prepare($sql);
$std->bindValue (":code", $code, PDO::PARAM_STR);
$std->execute();
$result = $std->fetchAll(PDO::FETCH_ASSOC);
if(count($result) ==0) {
echo 'U heef geen review geschreven, <a href="schrijven_review.php">Klik hier </a> om een review te schrijven';
} else {
echo '<table>';
foreach ($result as $index => $value){
$code = $value['Reviewnr'];
echo '
<tr>
<td class="bold"> Review nr: </td>
<td> '.$value['Reviewnr'].'</td>
</tr>
<tr>
<td class="bold"> Laatst gewijzigd op: </td>
<td> '.$value['Laatste_wijzigingsdatum'].'</td>
</tr>
<tr>
<td class="bold"> Geplaatst op:</td>
<td>'. $value['Plaatsings_datum'].'</td>
</tr>
<tr>
<td class="bold"> Titel: </td>
<td>'. $value['Titel'].'</td>
</tr>
</table>
<table>
<tr>
<td class="bold"> Review: </td>
</tr>
<tr>
<td>'. $value['Inhoud'].'</td>
</tr>
';
}
echo '</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.