I'm using PHPMyAdmin to manage my database, and I'm currently trying to use one for a project for school.
I'm using a TinyMCE text editor to make people add text. 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 .
I want the <p>
to be gone. 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.
Please help me get rid of the "< p>" in the text area.
You can use strip_tags( )
( http://us1.php.net/strip_tags ) to remove HTML tags from a string.
I think the best solution for your scenario would be to simply output the HTML outside of the textarea. Doing that will display the "styled" text/rendered HTML that the user created in TinyMCE.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.