I am using codeigniter and at the moment I have a bit of the problem. When I insert iframe (from the youtube) into db in the view file I get row code like this:
<iframe width="420" height="315" src="http://www.youtube.com/embed/aWvcNkRJhHw" frameborder="0" allowfullscreen></iframe>
How to insert iframe into db and display it properly?
EDITED PART:
Form for inserting:
<h3>Create News</h3>
<?php echo form_open('news/create_news') ?>
<label for="title">Title</label><input type="text" name="title" class="inputBox" id="title"><br>
<label for="body">Text</label><textarea name="body" class="inputBox" id="body" rows="5"></textarea>
<label for="datepicker">Date</label><input type="text" name="date" class="inputBox" id="datepicker">
<input type="submit" name="submit" value="Create" class="submit" />
<input type="reset" class="button standard" value="Clear" />
<?php echo form_close() ?>
Function for inserting:
function create_news()
{
$data = array(
'title' => $_POST['title'],
'body' => $_POST['body'],
'date' => $_POST['date']
);
$this->db->insert('news', $data);
}
I tried to insert iframe from youtube (embed video) but it does not work very well. When I load view file I just get text instead of video ().
Controller function:
function news() {
$this->load->helper('text');
if ($this->session->userdata('is_logged_in') == true) {
$q = $this->news_model->get_all();
if ($q == false) {
$data['np'] = 'There is no news at the moment.';
} else {
$data['news'] = $q;
}
$this->pagg();
$data['main_content'] = 'admin_news';
$data['title'] = 'Admin News';
$this->load->view('admin/template', $data);
} else {
$this->index();
}
}
View file:
<div id="news">
<?php if (isset($np)) { echo '<p>' . $np . '</p>'; } ?>
<?php if (isset($news)) : ?>
<?php foreach ($news as $row) : ?>
<div class="borderBott col_12">
<h3><a href="<?php echo base_url() ?>admin/news_update/<?php echo $row['title'] . "/" . $row['id_news'] ?>" ><?php echo $row['title'] ?></a></h3>
<p class="<?php echo alternator('par', 'nepar') ?>"><?php echo word_limiter($row['body'], 50); ?></p>
<p>Date written: <?php echo $row['date'] ?></p>
<a href="#" class="delete" id="<?php echo $row['id_news'] ?>">Delete News</a>
</div>
<?php endforeach; ?>
<?php endif; ?>