language file name can't retrieved from database... need help..

Discussion in 'PHP' started by s.jns, Jul 6, 2010.

  1. #1
    I am wondering if anyone out there can help with my language SCRIPT Please?

    <?php
    
    function select_lang(){
    echo '<select name="SITE_LANG" id="select8">';
    
    $lang = opendir("../lang");
        while($longFileName = readdir($lang)) {
            if ($longFileName[0] != "." && $longFileName[0] != ".." ) {
            $shortFileName = str_replace(array('', '.php'), '', $longFileName);
    		?>
                    <option value="<?php echo $shortFileName;?>" <?php echo ($SITE_LANG == $shortFileName) ? 'selected="selected"' : ''; ?>><?php echo $shortFileName;?></option>
    		<?php
            $count++;
            }
        }
        echo '</select>';
    closedir($lang);
    }
    ?>
              <tr>
                <td ><b>Site Languange</b></td>
                <td>
                  <?php select_lang(); ?>
                </td>
              </tr>
    PHP:
    the problem is the <?php echo ($SITE_LANG == $shortFileName) ? 'selected="selected"' : ''; ?> can't retrieved from mysql database as matched with files in the directory and then showing as selected language...
     
    s.jns, Jul 6, 2010 IP