geatzo Posted July 23, 2023 Share Posted July 23, 2023 Im storing photos / videos in a database i store the file name and the file location in the database now im trying to output them $query = $db->prepare('SELECT * FROM posts WHERE username=? ORDER BY id'); $query->execute( array($_SESSION['userid'] ) ) ; // alternatively you could use PDOStatement::fetchAll() and get rid of the loop // this is dependent upon the design of your app while ($row = $query->fetch(PDO::FETCH_ASSOC)) { if ($row['extension']== "mp4") { ?> <video width='150' height= '100' controls> <source src='users/<?php echo $_SESSION['userid'] ; ?>/<?php echo $row['photo'] ; ?>.<?php echo $row['extension'] ; ?>' type='video/mp4'> Your browser does not support the video tag. </video> <?php }else { ?> <li><a href="gallery.php"><img src="users/<?php echo $_SESSION['userid'] ; ?>/<?php echo $row['photo'] ; ?>.<?php echo $row['extension'] ; ?>" alt="Gallery"></a></li> <?php } }?> so im doing it has if the extention is mp4 it will view the player if its a photo it will display the image the problem im having is video files users upload are not just mp4 so how can i add it so if = mp4 or etc ? Quote Link to comment https://forums.phpfreaks.com/topic/317113-muti-if-statements/ Share on other sites More sharing options...
Solution ginerjm Posted July 23, 2023 Solution Share Posted July 23, 2023 Do you mean: if ($row['extension'] == "mp4" || $row['extension'] == "xxx" || $row['extension'] == "aaa") { // show this file } elseif ($row['extension'] == "jpg" || $row['extension'] == "jpeg" || $row['extension'] == "txt") { // show this file instead } Quote Link to comment https://forums.phpfreaks.com/topic/317113-muti-if-statements/#findComment-1610684 Share on other sites More sharing options...
geatzo Posted July 23, 2023 Author Share Posted July 23, 2023 7 minutes ago, ginerjm said: Do you mean: if ($row['extension'] == "mp4" || $row['extension'] == "xxx" || $row['extension'] == "aaa") { // show this file } elseif ($row['extension'] == "jpg" || $row['extension'] == "jpeg" || $row['extension'] == "txt") { // show this file instead } thank you this is what i need so if the extension is a video file i show the video if the extension is a photo i show the photo Quote Link to comment https://forums.phpfreaks.com/topic/317113-muti-if-statements/#findComment-1610685 Share on other sites More sharing options...
ginerjm Posted July 23, 2023 Share Posted July 23, 2023 HTH Quote Link to comment https://forums.phpfreaks.com/topic/317113-muti-if-statements/#findComment-1610686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.