dongzhukuai8177 2013-09-27 08:37
浏览 31
已采纳

图像进入提交按钮

Need some help getting the images into submitbuttons.

I am using a while loop to fetch multiple images from database and in the same time trying to create a form with a submitbutton displaying the image for each new image fetched.

I can't use CSS to have an image as a submitbutton since I am fetching multiple images with mysql to create multiple submitbuttons.

This explains what I'm trying to do. And btw, it has to be done in PHP, not javascript.

<?php 

$connect = mysql_connect("host", "user", "password") or die ("didn't con to db");
mysql_select_db("database") or die ("Couldn't find db");

$query = "SELECT  `Image` FROM database WHERE Genre='$genre'";

if ($query_run = mysql_query($query)) {

    while ($query_row = mysql_fetch_assoc($query_run)) {  

        $image = $query_row['Image'];
        $info = $query_row['Info'];
        $comments = $query_row['Comments'];
?>

    <form name=Form4 action="nextpage.php" method="post">  
        <input type="hidden" value="<?php echo $info; ?>" name="Info" />  
        <input type="hidden" value="<?php echo $comments; ?>" name="Comments" />  
        <input type="submit" class="imagebutton" value="<?php echo $image; ?>" > 
        <img src="<?php  echo $image; ?>" alt="" height="92" ></> 
    </form> 

<?php

//end of loop
    }
} else {
  echo 'Query failed. (something wrong in the code)';
}

?> 
  • 写回答

1条回答 默认 最新

  • douzhan5058 2013-09-27 08:47
    关注

    It seems your code have syntax error. Your code is like this

    <img src="<?php  echo $image; ?>" alt="" height="92" ></>
    

    Note that tag img is like this <img />, not this <img></>

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器