Hej Jag är helt nybörjare på php men har fått hjälp
med en liten sök funktion till mina mp3:or.
Jag har fixat en mp3.txt fil med all mina mp3:or med hjälp av
find /home/MP3* | grep -i .mp3 > /www/htdocs/mp3.txt
och sen så kommer min sök funktion i php här:
<html>
<title>File Search</title>
<body>
<form method="post" action="search.php" class=field>
MP3:
<input type="text" name="search" size="30"> <input value="search" type="submit" name="submit"><br> <br>
</form>
</form>
<?php
$file = "http://192.168.0.1/mp3.txt";
$search = addslashes(trim($search));
$searcha = explode(" ", $search);
$fd=fopen("$file","r");
$i = 0;
while ($line=fgets($fd,1000))
{
$search_array[$i] = $line;
$i++;
}
fclose ($fd);
if ($search)
{
reset($search_array);
while (list($key, $val) = each($search_array))
{ $i = 0;
$notcorrect = FALSE;
reset ($searcha);
while (list($key1,$val1) = each($searcha))
{
// echo $searcha[$i];
if (!stristr($val, $searcha[$i]))
$notcorrect = TRUE;
$i++;
}
// echo $notcorrect;
if (!$notcorrect)
echo("<font size=\"2\">" . $val . "</font><br>");
}
}
?>
</body>
</html>
Problemet är att den inte funkar ser du något fel ?
Han som gjorde detta e bortrest och skulle gärna vilja ha detta fungerande så fort som möjligt.
Tack på förhand.