Jump to content

PHP Selected PDF


amwd07

Recommended Posts

Can anyone help me with the following:

 

The code below displays only PDF's from a specific folder then on submit enters into the DB

This works great but what I need is, if field event_pdf1 displays a PDF this should be shown at the top of the dropdown. If I take out the below code and just echo $eventpdf1, this works but using $eventpdf1

within the functions fails. Anyone have any idea's?

 

///// Events PDF 1 /////
function eventPDF1($path){
echo "<div class=library_files>";
echo "<select name='event_pdf1' id='event_pdf1'>";
if ($handle = opendir($path)){
while (false !== ($file = readdir($handle))){ 
if (strpos($file, '.pdf',1)){
$dine = $_GET['dine_id'];
$fName = $file;
$file = $path.'/'.$file;
if(is_file($file)) {
// echo "<option value='$eventpdf1' selected='selected'>$eventpdf1</option>";
echo "<option value=''>None</option>";
echo "<option value='$fName'>$fName</option>";}}}
closedir($handle);}}echo "</select></div>";

 

 

echo $eventpdf1

Link to comment
https://forums.phpfreaks.com/topic/99607-php-selected-pdf/
Share on other sites

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.