Answer the question
In order to leave comments, you need to log in
How to properly display the path to the video from the database?
There is a video table and it also has a video field, in which I want to store the paths to my video
. And then, I want to remove this path from the database and immediately throw it into the video. Here's what I'm doing:
model
<?php
namespace frontend\models;
use yii\db\ActiveRecord;
//use yii\web\IdentityInterface;
class Video extends ActiveRecord{
public static function tableName(){
return 'video';
}
}
public function actionVideo()
{
$video = Video::find()->select('id, video');
return $this->render('video', compact('video'));
}
<div class="panel-body">
<video width="100%" height="auto" preload="auto" autoplay="autoplay"
loop="loop" poster="bg/daisy-stock-poster.jpg">
<source src="<?=$video?>" type="video/mp4"></source>
</video>
</div>
Answer the question
In order to leave comments, you need to log in
We change this:
$video = Video::find()->select('id, video')->all();
return $this->render('video', compact('video'));
$video = Video::find()->select('id, video')->all();
return $this->render('video', ['video'=>$video]);
<?=$video?>
accessed it as a string<?php foreach($video as $one): ?>
<div class="panel-body">
<video width="100%" height="auto" preload="auto" autoplay="autoplay"
loop="loop" poster="bg/daisy-stock-poster.jpg">
<source src="<?=$one->video?>" type="video/mp4"></source>
</video>
</div>
<?php endforeach; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question