显示A Db中的图像

时间:2014-05-02 20:46:10

标签: php sql

我有一个搜索栏(是的我知道它对SQL注入很有用)但是我需要知道如何显示图像: 这是DB: ItemID名称价格描述图像 1星球大战9.99“blah blah”starwars.jpg

此代码显示名称和描述,但不显示图像

                 <?php

if(!isset($_POST['search']))
{
    header("Location:index.php");

}

$search_sql="SELECT * FROM php_item WHERE Name LIKE '%".$_POST['search']."%' OR Description LIKE '%".$_POST['search']."%'";
$search_query = mysql_query($search_sql);
if(mysql_num_rows($search_query)!=0)
{

$search_rs= mysql_fetch_assoc($search_query);
}


?>


          </p>
          <p>&nbsp; Search Results: <a href="search.php" title="search again">Search Again</a></p>
          <?php

          if(mysql_num_rows($search_query) != 0){
              do{ ?>

              <p>
              <?php echo $search_rs['Name']; 
              echo $search_rs['Description'];
               ?> 

             <?php }while($search_rs=mysql_fetch_assoc($search_query));





          } else {
            echo "No Results Found";  
          }





          ?> 

1 个答案:

答案 0 :(得分:0)

这些方面应该有效

if(mysql_num_rows($search_query) != 0){
          do{ ?>

          <p>
          <?php echo $search_rs['Name']; 
          echo $search_rs['Description'];
          echo "<img src='$search_rs['Img']'
                 .jpg/>";
           ?> 

         <?php }while($search_rs=mysql_fetch_assoc($search_query));





      } else {
        echo "No Results Found";  
      }