drpzr64329 2016-07-31 14:48
浏览 73
已采纳

如何定义在html页面中单击哪个图像并使用php将图像名称存储在mysql中

my project is web image Re-Ranking. I am try to get which image is selected in the html page for update the rank of image in Mysql. My code is

index.php

<?php 


 include './search_image.php';

 $obj_image = new Image();

 if(@$_POST['Submit'])
{
$obj_image->image_name=str_replace("'", "''", $_POST['txt_image_name']);

$obj_image->Insert_into_image();

$data_image=$obj_image->get_all_image_list();
$row=mysql_num_rows($data_image);
}

 ?>



  <!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
   <html>
  <head>
   <title>Home</title>
  </head>
   <body bgcolor=cyan>
   <script>
   window.location.hash="no-back-button";
    window.location.hash="Again-No-back-button";//again because google chrome          don't insert first hash into history
   window.onhashchange=function(){window.location.hash="no-back-button";}
  </script> 
  <center><h1>WEB IMAGE RERANKING</H1></CENTER>
  <center>
  <table border=0 cellspacing=10>
  <th><a href="index.php" target="right">HOME</th>
  <th><a href="admin.php" target"=right">ADMIN</th>
  <form method="post" enctype="multipart/form-data">
  <tr>
   <th width="50%">Enter Image name for search</th>
   <td width="50%"><input type="text" name="txt_image_name"></input></td>
  </tr>
   <td width="50%"><input type="submit" name="Submit" value="Submit"></input>     </td>
   </tr>
   </table>
  </form>
   </CENTER>




   <?php 
  if($row!=0)
  {
   ?>
  <center>
  <form method="post" enctype="multipart/form-data">

  <table width="30%" border="0"> 
  <?php

     while($data= mysql_fetch_assoc($data_image))
   {
    ?>
   <tr>

    <a href=# onclick="loadImage(String $data['image'])"> <img  src="images/<?php echo $data['image']; ?>"  width="400px" height="200px" ></a>
    </tr>
    <?php
    }
    ?>
    </table>
    </form>
    </center>
   <?php
    } 

    ?>
    <?php
     echo" <script language='javascript' type='text/javascript'>
function loadImage(String a) {

      alert('1 %s',a);
     }
     </script>"
     ?>
   </body>
   </html>

search_image.php

   <?php
        include 'db_connection.php' ;

      class Image{

     var 
     $image_id,
       $image_name,
       $image;

      function Insert_into_image(){

         }

        function get_all_image_list(){
       $query = "select *from stor_image where img_name='$this->image_name'";
       $result = mysql_query($query);
       return $result;
       }

       }
       ?>

when click on specific image update the rank of the image. So I need help to find image name or src for update the data in mysql database. Thank you

  • 写回答

2条回答 默认 最新

  • douge7771 2016-07-31 17:56
    关注
     HTML:
     <a href="javascript:void(0);" class="gallery" id="<?php echo $data['image']; ?>" onClick="reply_click(this.id)"><img  src="images/<?php echo $data['image']; ?>"  width="400px" height="200px" ></a>
     <script>
     function reply_click(clicked_id)
     {
        $imagename=clicked_id;
        alert($imagename);
     }
     </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题