Jump to content

[SOLVED] is there any way i can do this?


yami007

Recommended Posts

??? i wonder if i can display files from a specific directory which arent stored in the database yet only, i wanna use this tool to show the files in my songs directory and i dont wanna see the files that i already have in my database

 

please help

Link to comment
https://forums.phpfreaks.com/topic/139279-solved-is-there-any-way-i-can-do-this/
Share on other sites

well there's a function called readdir, i know but it displays all the files in the directory

for ex: i'm displaying a folder of my website mp3, i use this tool to check if the file is already in my mp3 directory and copy and paste into my database, but i only dont want to display the mp3 files that i already have in the data..

OK guys i've done it, thanks anyway

for the ones who wants to know this is how i finally came up with a nice result ^^

 

<?php require_once("../includes/connection.php"); ?>
<html>
  <head>
     <title>Show songs</title>
  </head>
  
<body bgcolor="#ffffff">
<?php
        $rep = Array();
        
        $handle = @opendir("../songs");
        while (false !== ($f = readdir($handle)))
        {
            if ($f != ".." && $f != "." && $f != "index.php" && $f != "Thumbs.db")
            {
                $rep[] = $f;
            }
}

    closedir($handle);
sort ($rep);
reset ($rep);
?>
<table width="700" cellspacing="0" cellpadding="0" border="1">
<tr>
  <th height="30">Titre</th>
  <th height="30">Source</th>
</tr>
<?php while (list ($key, $filename) = each ($rep)) {
          	list ($name, $ext) = split ('[.]', $filename);


?>
<?php
  $html = "<tr>
<td height=\"30\"><input type=\"text\" value=\"$name\"></td>
<td height=\"30\"><input  type=\"text\" value=\"$filename\"></td>
</tr>";
?>
<?php 
$checkSong = mysql_query("SELECT source FROM songs WHERE source='$filename'");
$song_exist = mysql_num_rows($checkSong); 
if ($song_exist > 0) { 
  unset($html);  
  } else {
   ($html);
  }
?>
<?php echo $html; ?>
<?php } ?> 	
</table>
</body>
</html>

;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.