dongyingming8970 2014-11-04 02:29
浏览 59
已采纳

如何通过MySQL在PHP中显示特定图像

I'm trying to display each specific image to display in PHP/HTML page, it's currently displaying all the pages but I would like it to only display one for whenever I type in the function.

My code:

 <div class="ser-grid-list img_style">
                            <div class="gallery1">


                            </div>
                        </div>
                        <div class="ser-grid-list img_style">
                            <div class="gallery1">

                            </div>
                        </div>
                        <div class="ser-grid-list img_style">
                            <div class="gallery1">

                            </div>
                        </div>
                        <div class="ser-grid-list img_style">
                            <div class="gallery1">
                                                            <?php
 $sql = "SELECT image FROM product"; //sql query
 $result = mysql_query($sql) or die(mysql_error($connection));
 while ($row = mysql_fetch_array($result)) //display the results
 {
 echo "<p><img src='../images/" . ($row['image']) . "'" . " " . " />"; 
 }

?>

What its doing:

http://puu.sh/cCs29/6769667d43.jpg

What I'm wanting to make them do is align from left to right. It was working with Static images coming through html but I decided to use a database. This was it prior

http://puu.sh/cCs5g/919c0c8c57.jpg

Thanks!

  • 写回答

2条回答 默认 最新

  • douzhicui2209 2014-11-04 02:30
    关注

    Simply get the id of your image just like this one

     $sql = "SELECT image FROM product where id=101";
    

    This is the easiest one? Am i missing something?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试