Drop down list in PHP page appearing blank -
i have drop down list gathers ocntents directory windows folders. once user chooses value , clicks on search, results pdf files contained in directory. turns out, cannot find reason why drop down list results blank. have included code screenshot of blank drop down list. curious enough, 1 record appears in drop down list shortcut link. please pardon ignorance, php newbie , code bit messy. running page on iis 7.
<?php // cmm_tino.php error_reporting(e_all); /** * search pdf files based on directory name */ // activate show request // var_dump($_get); function getfilelist($dir) { // array hold return value $retval = array(); // add trailing slash if missing if(substr($dir, -1) != directory_separator) $dir .= directory_separator; // open pointer directory , read list of files $d = @dir($dir) or die("getfilelist: failed opening directory $dir reading"); while(false !== ($entry = $d->read())) { // skip hidden files if($entry[0] == ".") continue; if(is_dir("$dir$entry")) { $retval[] = array( "name" => "$dir$entry" . directory_separator, "type" => filetype("$dir$entry"), "size" => 0, "lastmod" => filemtime("$dir$entry") ); } elseif(is_readable("$dir$entry")) { $retval[] = array( "filename" => "$entry", "filepath" => "$dir$entry" ); } } $d->close(); return $retval; } // links pdf files, if $links = null; // put path directory of file folders here $path = './cmm_search/cmm'; // list of file folders $folders = array_diff(scandir($path), array('.','..')); // filter list of file folders remove extraneous files foreach ($folders $key => $name) { if (!is_dir($path . directory_separator . $name)) unset($folders[$key]); } // if there request $q = !empty($_get['q']) ? $_get['q'] : null; if (!empty($q)) { // if request matches 1 of file folders $folder = null; foreach ($folders $folder) { if (strpos($folder, $q) !== false) break; $folder = null; } if ($folder) { $links = "<p><b>$folder</b></p>" . php_eol; // list of files in folder $files = array_diff(scandir($path . directory_separator . $folder), array('.','..')); // prepare links pdf files foreach ($files $file) { $end = explode('.', $file); $end = end($end); $end = strtoupper($end); if ($end != 'pdf') continue; $links .= '<br>' . '<a target="my_pdf" ' . 'href="' . $path . directory_separator . $folder . directory_separator . $file . '">' . $file . '</a>' . php_eol ; } } else { $links = '<br>' . 'unknown folder: ' . "<b>$q</b>" . php_eol ; } } // create search page using php heredoc notation $htm = <<<eod <!doctype html> <html> <head> <title>barfield cmm lookup</title> <meta name="robots" content="noindex, nofollow" /> <!-- css styles standard search box --> <style type="text/css"> #tfheader{ background-color:#; } #tfnewsearch{ float:center; padding:20px; width: 1686px; } .tftextinput{ margin: 0; padding: 5px 15px; font-family: arial, helvetica, sans-serif; font-size:14px; border:1px solid #0076a3; border-right:0px; border-top-left-radius: 5px 5px; border-bottom-left-radius: 5px 5px; } .tfbutton { margin: 0; padding: 5px 15px; font-family: arial, helvetica, sans-serif; font-size:14px; outline: none; cursor: pointer; text-align: center; text-decoration: none; color: #ffffff; border: solid 1px #0076a3; border-right:0px; background: #0095cd; background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5)); background: -moz-linear-gradient(top, #00adee, #0078a5); border-top-right-radius: 5px 5px; border-bottom-right-radius: 5px 5px; } .tfbutton:hover { text-decoration: none; background: #007ead; background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e)); background: -moz-linear-gradient(top, #0095cc, #00678e); } /* fixes submit button height problem in firefox */ .tfbutton::-moz-focus-inner { border: 0; } .tfclear{ clear:both; } .auto-style1 { width: 915px; height: 90px; margin-left: 0px; } .auto-style2 { color: #0033cc; } </style> </head> <body> <!-- html search bar --> <div id="tfheader"> <br /> <img alt="barfield" class="auto-style1" src="barfield.jpg" /><br /> <!-- ************** note $links variable filled in php script ************** --> $links <br /> <!-- ************** note action attribute removed cause script send form request current url ************** --> <form id="tfnewsearch" method="get"> <span class="auto-style2"><strong>cmm</strong> </span> <select class="tftextinput"> eod; define('root', getenv("document_root") . directory_separator); $res = getfilelist(root . 'cmm_search' . directory_separator . 'cmm' . directory_separator); foreach ($res $file){ $htm .="<option>" . $file['filename'] . "</option>"; } $htm .= <<<eod </select> <input type="submit" value="search" class="tfbutton"> </form> <form id="tfnewsearch" method="get"> <span class="auto-style2"><strong>addn documents</strong> </span> <input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton"> </form> <form id="tfnewsearch" method="get"> <span class="auto-style2"><strong>part number</strong> </span> <input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton"> </form> <img src='./qcjoe.jpg' width='200' height='200' /> dev 1.1r1
eod;
// write html document browser echo $htm;
Comments
Post a Comment