duan5801 2013-08-10 04:19
浏览 18
已采纳

如何检索和显示基于URL和Product-ID的图像?

I re post my code here.. Am keep getting the error of :

Notice: Undefined index: Image URL in C:\wamp\www\mySql1.php on line 35..

my URL value in the pimage table is : 'c:\wamp\www\toy1.jpg'. May i know is this correct?? Really appreciate anyone kind response and help..

<html>
<head></head>
<body>
<?php
//open connection to MySQL Server
$connection = mysql_connect('localhost','root', '')
        or die ('Unable to connect to !');

// select database for use
mysql_select_db('we-toys') or die ('Unable to select database!');

$query = 'select * from product p, pimage p2 where p.pid=p2.imagepid';
$result = mysql_query($query)
        or die ('Error in query: $query. ' . mysql_error());

if (mysql_num_rows($result) > 0)
{
    echo '<table width = 100% cellpadding = 10 cellspacing = 0 border = 1>';
    echo '<tr><td><b>ID</b></td>
      <td><b>PName</b></td>
      <td><b>PGroup</b></td>
          <td><b>PType</‌​b></td>
          <td><b>Qty</b></td>
          <td><b>Image></b></td>';

    while ($row = mysql_fetch_row($result)) 
    { echo '<tr>
    <td>'.$row[0].'</td>
    <td>'.$row[2].'</td>
    <td>'.$row[4].'</td>
    <td>'.$row[5].'</td>
    <td>'.$row[6].'</td>
    <td><img src="'.$row['ImageURL'].'"></td>
    </tr>'; 
} 
echo '</table>'; 

}
        else
        {
            echo 'No rows found!';        
        }
        mysql_free_result($result);
        mysql_close($connection);
     ?>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • dpr26232 2013-08-10 04:26
    关注
    <?php echo '<table width = 100% cellpadding = 10 cellspacing = 0 border = 1>
    <tr><td><b>ID</b></td>
    <td><b>PName</b></td>
    <td><b>PGroup</b></td>
    <td><b>PType</‌​b></td>
    <td><b>Qty</b></td>
    <td><b>Image></b>
    </td></tr>';
    while ($row = mysql_fetch_array($result)) 
    { echo '<tr><td>'.$row[0].'</td>
    <td>'.$row[2].'</td>
    <td>'.$row[4].'</td>
    <td>'.$row[5].'</td>
    <td>'.$row[6].'</td>
    <td><img src="'.$row['ImageURL'].'"></td></tr>'; } 
    echo '</table>'; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序