php - Display video (by url) and all the information about it from database using single loop -


basically, have vid table in db columns - urlv, textacv,decribacv, languagev,levelv , need display videos in database (using url - urlv) , along video want display name(textacv) , description(decribacv) , tags(languagev,levelv) of each video.

currentely have achieved have page videos displayed database url. here how i've made this:

$conn = mysqli_connect('localhost','root','','people');  $query = "select urlv, languagev,      levelv, textacv, decribacv vid"; $fetch = mysqli_query($conn,$query); $videos = array(); while ($row = mysqli_fetch_assoc($fetch)) {     $videos[] = $row['urlv'];     $language[] = $row['languagev'];     $levelv[] = $row['levelv'];     $textac[] = $row['textacv'];     $decribac[] = $row['decribacv']; } foreach ($videos $urlv) {      echo "<div class='wrap'>         <div class='video-wrap'>         <div class='blockvidname'>         <div class='name'><legend class='name-top'>".             $textac."</legend></div>         <video class='video'controls>         <source src='".$urlv."'>         </video>         <div class='name-bot'><legend class='name-bottom'>             name of  video</legend></div>         </div>         <div class='side-bar-wrap'> dfdfdf </div>         <button class='side-bar-  button'>more info</button>         </div>         </div>"; } 

as can see - i've used foreach loop retrieve url database , display videos, need 'attach' name, description , tags each video acordinaly table vid. here's did:

while ($row = mysqli_fetch_assoc($fetch)) {     $videos[] = $row['urlv'];     $language[] = $row['languagev'];     $levelv[] = $row['levelv'];     $textac[] = $row['textacv'];     $decribac[] = $row['decribacv']; } while($row) {      echo "<div class='wrap'>         <div class='video-wrap'>         <div class='blockvidname'>         <div class='name'><legend class='name-top'>".         $textac."</legend></div>         <video class='video'controls>         <source src='".$urlv."'>         </video>         <div class='name-bot'><legend class='name-bottom'>             name of video</legend></div>         </div>         <div class='side-bar-wrap'> dfdfdf </div>         <button class='side-bar-button'>more info</button>         </div>         </div>"; } 

but doesnt display @ all! googled 'multiple arguments in foreach loop' found nothing me.

the problem - cant display multiple data in single loop (because have nestings in html structure , multiple loops brake it) db. note: want videos in table displayed , each name, descriptiob etc. want attach each video accordinally db.

thanks lot! i'm stuck on thing. in advance.

you're kind of on complicating things trying put columns own arrays. it's manageable, not necessary. doing in initial while loop.

while ($row = mysqli_fetch_assoc($fetch)) { ?>     <div class='wrap'>         <div class='video-wrap'>             <div class='blockvidname'>                 <div class='name'>                    <legend class='name-top'><?php echo $row['textacv'] ?></legend>                 </div>                <video class='video' controls>                    <source src="<?php echo $row['urlv']?>">                </video>                <div class='name-bot'>                    <legend class='name-bottom'>                        name of video                    </legend>                </div>            </div>            <div class='side-bar-wrap'> dfdfdf </div>            <button class='side-bar-button'>more info</button>         </div>     </div> <?php } ?> 

then use index of row when echo'ing. should pretty straight forward here.


Comments