I am using PHP to create and index of the files contained in a directory. I then echo the files by including the index function in another php script. How can I change where the PHP shows up? It currently shows up at the top of the page but I would like to inject it into a specific DIV. I've tried using innerHTML in JavaScript but have had little success.
code is below:
<?php
function Indexer($indexer) {
switch ($indexer) {
case "A":
$indexLocation="gloss/A";
return $indexLocation;
break;
case "B":
$indexLocation="gloss/B";
return $indexLocation;
break;
case "C":
$indexLocation="gloss/C";
return $indexLocation;
break;
case "D":
$indexLocation="gloss/D";
return $indexLocation;
break;
case "E":
$indexLocation="gloss/E";
return $indexLocation;
break;
case "F":
$indexLocation="gloss/F";
return $indexLocation;
break;
case "G":
$indexLocation="gloss/G";
return $indexLocation;
break;
case "H":
$indexLocation="gloss/H";
return $indexLocation;
break;
case "I":
$indexLocation="gloss/I";
return $indexLocation;
break;
case "J":
$indexLocation="gloss/J";
return $indexLocation;
break;
case "K":
$indexLocation="gloss/K";
return $indexLocation;
break;
case "L":
$indexLocation="gloss/L";
return $indexLocation;
break;
case "M":
$indexLocation="gloss/M";
return $indexLocation;
break;
case "N":
$indexLocation="gloss/N";
return $indexLocation;
break;
case "O":
$indexLocation="gloss/O";
return $indexLocation;
break;
case "P":
$indexLocation="gloss/P";
return $indexLocation;
break;
case "Q":
$indexLocation="gloss/Q";
return $indexLocation;
break;
case "R":
$indexLocation="gloss/R";
return $indexLocation;
break;
case "S":
$indexLocation="gloss/S";
return $indexLocation;
break;
case "T":
$indexLocation="gloss/T";
return $indexLocation;
break;
case "U":
$indexLocation="gloss/U";
return $indexLocation;
break;
case "V":
$indexLocation="gloss/V";
return $indexLocation;
break;
case "W":
$indexLocation="gloss/W";
return $indexLocation;
break;
case "X":
$indexLocation="gloss/X";
return $indexLocation;
break;
case "Y":
$indexLocation="gloss/Y";
return $indexLocation;
break;
case "Z":
$indexLocation="gloss/Z";
return $indexLocation;
break;
}
}
function renderIndex(){
if(isset($_GET['gloss']))
{
$html=indexer($_GET['gloss']);
$handle = opendir($html);
while (false !== ($file = readdir($handle))) {
$exploded = explode(".", $file);
$mang="<a id='gloss' href='#'".$file."'>".$exploded[0]."</a><br>";
}
closedir($handle);
} else {
}
}
and this in the html file where i want the code to appear:
include_once 'renderIndex.php';