产品ID链接

时间:2014-04-05 13:33:33

标签: php sql

我试图显示带有链接的产品ID,但我似乎无法正确使用它。它是ID和我遇到问题的链接。

Iv将脚本复制到另一个工作正常的文档中。

require "db.inc";

// open connection 
$connection = mysql_connect($hostname, $username, $password) or die ("Unable to     connect!"); 

// select database 
mysql_select_db($databaseName) or die ("Unable to select database!"); 

// create query 
$query = "SELECT * FROM protien"; 
//Check initial letter
// execute query 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

// see if any rows were returned 
if (mysql_num_rows($result) > 0) { 
// yes 
// print them one after another 
echo "<table cellpadding=10 border=0>"; 
    echo "<tr>"; 
    echo "<th>" ?>Image<?php "</th>"; 
    echo "<th>" ?>Brand<?php "</th>";
    echo "<th>" ?>Type<?php "</th>";
    echo "<th>" ?>Price<?php "</th>";
    echo "<th>" ?>Description<?php "</th>";
    echo "</tr>";

  while($row = mysql_fetch_assoc($result)) { 
    echo "<tr>"; 
    echo"<td>""<a href=Ammend.php?memberID=.$row['memberID']>.$row['memberID'].</a>""    </td>";
    echo "<td>"."<img src=../Products/".$row['ProductImage']."> </td>";
    echo "<td>".$row['ProductBrand']."</td>"; 
    echo "<td>".$row['ProductType']."</td>"; 
    echo "<td>£".$row['ProductPrice']."</td>";
    echo "<td>".$row['ProductDescription']."</td>";


    echo "</tr>"; 
  } 
  echo "</table>"; 
 } 
 else { 
  // no 
 // print status message 
 echo "No rows found!"; 
} 

1 个答案:

答案 0 :(得分:1)

第一个“td”行应该是这样的

echo "<td><a href=Ammend.php?memberID=" . $row['memberID'] . ">" . $row['memberID'] . "</a> </td>";

您需要向我们提供您的输出以查看错误的位置,但我认为您已经有了这个想法......