尝试创建显示图像的搜索表单

时间:2017-10-31 22:31:13

标签: php mysql phpmyadmin

<?php
mysql_connect("x","y","z!") or die("Could not connect");
mysql_select_db("x") or die("Could not connect");

$output = '';
// Collect 
if(isset($_POST['search'])) {
    $searchq = $_POST['search'];

    $query = mysql_query("SELECT * FROM uni_slider WHERE slider_name LIKE '%$searchq%' OR slider_image LIKE '%$searchq%' OR slider_price LIKE '%$searchq%'") or die("Could not search");
    $count = mysql_num_rows($query);
    if($count == 0){
        $output = 'There was no such results';
    }else{
        while($row = mysql_fetch_array($query)) {
                $name = $row['slider_name'];
                $image = $row['slider_image'];
                $price = $row['slider_price'];


                $output .= '<div class="output">'?><img src="/upload/<?php echo $row['slider_image'];?>"><?php <br/> '.$name.' <br/> '.$price.' <font color="#2ecc71">$</font><br/></div>;
        }
    }
}
?>

这是我的代码,现在输出部分不起作用。如果我像这样编写代码

$output .= '<div class="output> '.$image.' <br/> '.$name.' <br/> '.$price.' <font color="#2ecc71">$</font><br/></div>';

它只显示图像文件名,而不是图像。

我试过`“&gt;但它给了我错误,任何帮助?谢谢

1 个答案:

答案 0 :(得分:-1)

非常简单,您忘记了关闭output它应该是<div class="output">然后将/upload/更改为网络根目录中的符号链接,您不能只放/something因为apache无法处理它。如果你说ln -s / upload uploadlink,如果你有shell访问权限可以工作