Error in showing index of series of videos from the database?

4
  

I have an error in displaying the results correctly

Errors, the problem I'm presenting

I get the id_series of the serial table and using the id related, it shows me the data from the chapters table until it is perfect.

  • Series 2017
  • 2016 series

Now the problem is that it shows me the same videos (video 1, video 2) in both chapters (series 2017, series 2016),

To solve it I must pass a new condition to the query not to show the same videos in both chapters, that is video 1, video 2, must belong to the 2017 series, strong> and in the 2016 series there are no chapters you should not show me any index of the videos.

I think I should add the id_chapters of the chapters table to the videos table

id_videos    title_video    description_video      multimedia    id_series    id_chapters

The other error is that in chapter 2 it shows me the + button and this button should not be displayed because they do not exist in the description_video the detail of the same video, this NULL

Structure of the database

Tables

series.

id_series      title           detail     author
   1        New serie 1      Serie 2017   anónimo
   2        New aventure 2   Serie 2016   anónimo

chapters.

id_chapters     chapters     id_series
    1          Serie 2017        1
    2          serie 2016        1

videos.

id_videos    title_video    description_video      multimedia    id_series
   1         video 1        En este capitulo...    video1.mp4        1
   2         video 2         NULL                  video2.mp4        1

I get the id of the series to show the data related to the series.

  if (isset($_GET['id'])){
    $id = $_GET['id'];
    $sql = "SELECT * FROM series WHERE url='".$id."'";
    $result = mysqli_query($con, $sql);

    if(mysqli_num_rows($result) > 0){
        while ($row = mysqli_fetch_array($result)) {
            $id = $row['id_series'];
        }
    }
  }

Example:

  

I show on the premieres.php page all the data in the series table when clicking on one of the series, go to the detalle.php page where through its id I show the results related to the rest of the tables.

    
asked by J. Mick 07.09.2017 в 17:54
source

1 answer

1

As you indicate, you must correct the relationship by adding id_chapter to video :

Tables

videos.

id_videos    title_video    description_video      multimedia    id_chapters
   1         capitulo 1     En este capitulo...    video1.mp4        1
   2         capitulo 2     NULL                   video2.mp4        1

Then adjust the query according to that field:

$get_videos = "SELECT * FROM videos WHERE id_chapters='".$row_chapters['id_chapters']."'";

For the problem of + Replace this section:

while ($row_videos = mysqli_fetch_array($run_videos)) {
        echo '<ul class="view">
        <li>
          <div class="rows">
            <div class="play"><img src="../material/moonicon-play.png"></div>
            <div class="video-title"><a>'.$row_videos['title_video'].'</a><span class="toggle"></span>
              <ul class="inner">
                <li>'.$row_videos['description_video'].'</li>
              </ul>
            </div>
            <div class="view-preview">&nbsp;Vista Previa</div>
            <div class="length">&nbsp;02:34</div>
          </div>
        </li>
        </ul>';
    }

For this:

while ($row_videos = mysqli_fetch_array($run_videos)) {
        echo '<ul class="view">
        <li>
          <div class="rows">
            <div class="play"><img src="../material/moonicon-play.png"></div>
            <div class="video-title"><a>'.$row_videos['title_video'].'</a>';
if(!is_null($row_videos['description_video'])){
    echo '<span class="toggle"></span>
              <ul class="inner">
                <li>'.$row_videos['description_video'].'</li>
              </ul>';
}
echo '</div>
            <div class="view-preview">&nbsp;Vista Previa</div>
            <div class="length">&nbsp;02:34</div>
          </div>
        </li>
        </ul>';
    }
    
answered by 07.09.2017 / 18:40
source