0

代码:

<?php
    $page = $_GET['page'];
    $category = $_GET['cat'];
    $your_db = @ new mysqli("database","name","password");
    if (mysqli_connect_errno())
    {
    echo 'ERROR!
    '.mysqli_connect_errno()
    .' - Not connected : '.mysqli_connect_error().'
    ';
    die;
    }
    else
    {
    $db_connect = $your_db->select_db("databasename");
    if (!$db_connect)
    {
    echo 'ERROR CONNECT DATA BASE';
    die;
    }
    }
    echo '<p>';
    $query = "select distinct fldCity from info order by fldCity";
    $result = $your_db->query($query);
    $number_of_records = $result->num_rows;
    for ($i = 0; $i < $number_of_records; $i++)
    {
    $row = $result->fetch_assoc();
    echo '<a href="index.php?cat='.stripslashes($row['fldCity']).'">';
    echo stripslashes($row['fldCity']);
    echo '</a>&nbsp;/&nbsp;';
    }
    echo '</p>';
    if ($category)
    {
    $query = "select fldCompanyLogo, fldCompanyName, fldAddress, fldCity, fldProvince, fldPostalCode, fldMenuLink
    from info where fldCity = '$category' and length(fldCompanyLogo) > 0 order by fldCity";
    }
    else
    {
    $query = "select fldCompanyLogo, fldCompanyName, fldAddress, fldCity, fldProvince, fldPostalCode, fldMenuLink
    from info where length(fldCompanyLogo) > 0 order by fldCity";
    }

    $result = $your_db->query($query);
    $number_of_records = $result->num_rows;
    $num_pages = $number_of_records / 7;
    if (($number_of_records % 7) > 0 )
    {
    $num_pages++;
    }
    if (strlen($page) == 0)
    {
    $page = 0;
    }
    else
    {
    $page = $page * 4;
    }
    echo '<table border="0" cellspacing="10" cellpadding="10" style="border-collapse: collapse" bordercolor="#111111">';
    $row_num = 4;
    $result->data_seek($page);
    for ($i = $page; $i < $number_of_records; $i++)
    {
    if ($row_num <= 4)
    {
    echo '<tr>';
    for ($col_num = 0; $col_num < 4; $col_num++)
    {
    $row = $result->fetch_assoc();
    echo '<td>';
    show_image(stripslashes($row['fldCompanyLogo']),stripslashes($row['fldCompanyName']));
    echo '
    ';
    echo '<b><font face="Tahoma" size="2"><a href="mysite.ca/'.stripslashes($row['fldMenuLink']).'" target="_blank"></font>';
    echo '<font face="Tahoma" size="2"><a href="'.stripslashes($row['fldMenuLink']).'" target="_blank">';
    echo stripslashes($row['fldCompanyName']);
    echo '</a>';
    echo '
    ';
    echo stripslashes($row['fldCity']);
    echo '
    ';
    echo stripslashes($row['fldProvince']);
    echo '
    ';
    echo stripslashes($row['fldPostalCode']);
    echo '</td>';
    }
    $row_num++;
    echo '</tr>';
    }
    else
    {
    break;
    }
    }
    echo '</table>';
    for ($j = 0; $j < $num_pages; $j++)
    {
    $page_link = $j + 1;
    echo '<font face="Tahoma" size="4"><b><a href="index.php?page='.$j.'&cat='.$category.'">'.$page_link.'</a></b></font>&nbsp;';
    }
    echo '&nbsp;'.$number_of_records;
    function show_image($image_name)
    {
    if (file_exists("'$image_name'"))
    {
    $dim_img = getimagesize('/images/'.$image_name);
    echo '<img src="/images/'.$image_name.'" alt = '.$alt.' border=0 align="bottom"';
    echo 'width = '. $dim_img[100] .' height = ' .$dim_img[100] . ' />';
    }
    else
    echo 'Add your image here!';
    }
    ?>

我完全迷失了,我找不到为什么数据库中的图像没有与脚本一起加载的错误。我用蓝色突出显示了我认为错误所在的区域。我只是在那个特定的地方找不到任何错误!我想要的只是从我的数据库中的列中获取并连接到“echo”的图像

没有显示图像,我找不到关于为什么图像没有显示的错误

4

1 回答 1

0

尝试将图像转换为Base64字符串和Base64字符串转换为图像

还有为什么 echo '';你用这个它没有意义

于 2012-11-26T09:04:15.253 回答