Hi i have to display the data from the query where downloaded='n' here in this i am displaying all the files available in the particular directory please help me how to do it?
please see the code and help me
<?
session_start();
$uid= $_SESSION['loguid'];
if($uid=='')
{
$_SESSION['loguid']="Guest";
$uid= $_SESSION['loguid'];
}
require("header.php");
error_reporting(0); //disables any PHP warnings or errors on the page.
$server=$HTTP_SERVER_VARS["SERVER_NAME"]; // provides the domainname
$link="http://$server/"; //main link
?>
<html>
<head>
<title>Trans-verse - Downloads page</title>
<meta http-equiv='Content-Type' content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.box {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
border: 1px solid #000000;
}
-->
</style>
</head>
<body>
<form action="downloads1.php" method="POST">
<table align="center">
<TR><TD>
<div class="containermain">
<div class="topnavi">
<? include "trans-verse.html" ?>
</div>
<?
include("../config.php");
$ob=new Configure;
$ob->connDB();
$ob->selDB();
include("example1.php");
$logintext='LOGIN';
$logouttext='Logout';
if($uid=="Guest")
{
print "<a href='../login.php'><font face=Arial color=black>$logintext</font></a> ";
}
if($uid!="Guest")
{
print "<a href='../logout.php'><font face=Arial color=black>$logouttext</font></a> ";
}
?>
<table border="0" cols="2" >
<?php
/*while($row=mysql_fetch_array($res,MYSQL_BOTH))
{
$filename=$row['voicefilenumber'];
//print $filename;
//$fname=split($filename,".",3);
$fileext=substr($filename,strlen($fileext));
print $fileext;
$fname=substr($filename,".",$filename);
print "Name:".$fname;
print "<tr> <td><a href=downloads1.php?id=$fname>$fname</a></td></tr>";
print "<tr> <td><A class=alpha href=\"downloads1.php\"> $fname</a> </td></tr>";
$file_ext= substr($fname,-4,4);
//$filename='mambo1.bmp';
$dir="./docproject";
echo $dir;
if (isset($_REQUEST["voicefilenumber"]))
{
$file=$dir.$_REQUEST["voicefilenumber"];
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".basename($file)."\"");
readfile("$file");
}
else
{
echo "No file selected";
}
}*/
echo ("<h1>File Directory:</h1>");
function getFiles($path) {
$files = array();
$fileNames = array();
$i = 0;
if (is_dir($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
if ($file == "." || $file == "..") continue;
//$fullpath=$path;
$fullpath = $path . "/" . $file;
[B]$fkey = strtolower($file);
$db=mysql_select_db('doctors');
$qry=mysql_query("select voicefilenumber from doctorfile where downloaded='N'");
$qry_2="select count(voicefilenumber) from doctorfile where downloaded='N'";
$res=mysql_query($qry_2);
while($row=mysql_fetch_array($res,MYSQL_BOTH))
{
//print mysql_affected_rows();
}
//print $row[0];
/*$docroot=$_SERVER['DOCUMENT_ROOT'];
$imgpath=$docroot.$path["dirname"]."/docfiles";
$path=pathinfo($_SERVER['PHP_SELF']);
$files=getFiles($docroot."/docproject/docfiles");[/B]
foreach ($files as $file) print "<li><a href=\"$file[name]\">$file[name]</a></li>"; */
while($row=mysql_fetch_array($qry,MYSQL_BOTH))
{
$filename=$row['voicefilenumber'];
//print $filename;
}
while (array_key_exists($fkey,$fileNames)) $fkey .= " ";
$a = stat($fullpath);
$files[$fkey]['size'] = $a['size'];
if ($a['size'] == 0) $files[$fkey]['sizetext'] = "-";
else if ($a['size'] > 1024) $files[$fkey]['sizetext'] = (ceil($a['size']/1024*100)/100) . " K";
else if ($a['size'] > 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/(1024*1024)*100)/100) . " Mb";
else $files[$fkey]['sizetext'] = $a['size'] . " bytes";
$files[$fkey]['name'] = $file;
$files[$fkey]['type'] = filetype($fullpath);
$fileNames[$i++] = $fkey;
}
closedir($dh);
} else die ("Cannot open directory: $path");
} else die ("Path is not a directory: $path");
sort($fileNames,SORT_STRING);
$sortedFiles = array();
$i = 0;
foreach($fileNames as $f) $sortedFiles[$i++] = $files[$f];
return $sortedFiles;
}
$docroot=$_SERVER['DOCUMENT_ROOT'];
$imgpath=$docroot.$path["dirname"]."/docfiles";
$path=pathinfo($_SERVER['PHP_SELF']);
$files=getFiles($docroot."/docproject/docfiles");
foreach ($files as $file) print "<li><a href=\"$file[name]\">$file[name]</a></li>";
function dl_file($file){
//First, see if the file exists
if (!is_file($file)) { die("<b>404 File not found!</b>"); }
//Gather relevent info about file
$len = filesize($file);
$filename = basename($file);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
//This will set the Content-Type to the appropriate setting for the file
switch( $file_extension ) {
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
case "mp3": $ctype="audio/mpeg"; break;
case "wav": $ctype="audio/x-wav"; break;
case "mpeg":
case "mpg":
case "mpe": $ctype="video/mpeg"; break;
case "mov": $ctype="video/quicktime"; break;
case "avi": $ctype="video/x-msvideo"; break;
//The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files)
case "php":
case "htm":
case "html":
case "txt": die("<b>Cannot be used for ". $file_extension ." files!</b>"); break;
default: $ctype="application/force-download";
}
//Begin writing headers
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
//Use the switch-generated Content-Type
header("Content-Type: $ctype");
//Force the download
$header="Content-Disposition: attachment; filename=".$filename.";";
header($header );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
readfile($file);
exit(1);
}
foreach ($files as $file) //print "<li><a href=\"$file[name]\">$file[name]</a></li>";
?>
<br>
<br>
<br>
<br>
<div align="left"><a href=../indexes.php>GoBack</a></div>
</table>
</TD>
</TR>
</table>
<?php require("body.php");
require("includes/footer.php");
?>
</form>
</body>
</html>
i need to display the records where the bold is there in the above php file
thanks in advance please help me