Jump to content

Muti if statements


geatzo
Go to solution Solved by ginerjm,

Recommended Posts

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 ?

Link to comment
Share on other sites

  • Solution

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
	}

 

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.