0

我在这里重新发布我的代码。我不断收到以下错误:

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

我在 pimage 表中的 URL 值为 : 'c:\wamp\www\toy1.jpg'。我可以知道这是正确的吗?真的很感谢任何人的友好回应和帮助..

<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>
4

1 回答 1

2
<?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>'; ?>
于 2013-08-10T04:26:32.190 回答