Ionut cosmin 0 Newbie Poster

Hi guys i am new here..i am not have more experience with php.I have one good script ,this search on folder from name the file,example pdf file.Worked ok all goood but i need add the limit rezult for show because i search pdf name for example and this show me all file pdf,no have limit on page for rezult.I need limit this only 15 rezults,and another question possible add the messsage file not found for rezult nothing existent.
thanks you very much!!

    $dir = 'data'; 
    $exclude = array('.','..','.htaccess'); 
    $q = (isset($_GET['q']))? strtolower($_GET['q']) : ''; 
    $res = opendir($dir); 
    while(false!== ($file = readdir($res))) { 
    if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) { 
    echo "<a href='$dir/$file'>$file</a>"; 
    echo "<br>"; 

and here is html

<form action="file.php" method="get">
<input name="q" type="text" /> 
<input type="submit" />
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.