为什么我的foreach循环中的代码无法访问? PHP

时间:2014-05-26 12:06:08

标签: php html phpmyadmin glob

嗨,这是我的一段代码,我不明白为什么我的foreach中的代码无法访问,

$content = "";
/*** the upload directory ***/
$upload_dir= '/gallery/school/'.$name.'/';

$images = glob($upload_dir."*.*");
foreach($images as $image) {

    $content .= '   <li>
       <img src="'.$image.'" alt="">
       <p class="caption">This is a caption</p>
       </li>';
} 

这是整个代码,foreach之前的代码完全正常。但是当我试图回显$ content时,里面的代码是无法访问的,它给出了空白输出,即$ content不包含任何东西

<?php

include "storescrpt/connect_to_sql.php";

if(isset($_GET['dc_id']))
{
    $day_care =     $_GET['dc_id'];
    $sql = mysql_query("select * from school where id='$day_care'");
    $count =mysql_num_rows($sql);
    if($count>0)
    {    
        while($row= mysql_fetch_array($sql))
        {  
            $name = $row['name'];
            $phone = $row['phone'];
            $address = $row['address'];
            $desc = $row['desc'];
            $Fac = $row['Fac'];
            $area = $row['area'];
            $gog = $row['gog'];     
        }
    }

    $content = "";
    /*** the upload directory ***/
    $upload_dir= '/gallery/school/'.$name.'/';

    $images = glob($upload_dir."*.*");
    foreach($images as $image) {
        echo $image;
        $content .= '   <li>
            <img src="'.$image.'" alt="">
            <p class="caption">This is a caption</p>
            </li>';
    }
}

?>

0 个答案:

没有答案