2012-04-28 85 views
0

這裏是我的PHP的我想提出一個按鈕在呼應表格單元格

echo "<table border='0'>"; 
while($list = mysql_fetch_assoc($result)) 
echo "<tr>"; 
echo "<td>" . $list['SALEPRICE']."</td>"; 

我想在與鏈接FOLLOWING BUYURL把一個按鈕的一部分。

echo "<td><a target='new' href=\"" . $list['BUYURL'] . "\"><b>VISIT STORE NOW</b></a></td>"; 
echo "</tr>"; 
echo "</table>"; 
+2

什麼是真正的問題,裏面的按鈕? – hjpotter92 2012-04-28 05:26:18

+1

祝你好運。 – 2012-04-28 05:28:39

+0

在表中,其中BUYURL如展示的細胞,我要按鈕,該按鈕,點擊時跟隨LINK。 – sanjay 2012-04-28 05:28:53

回答

1

只需使td標記的backround顏色成爲按鈕的顏色,它會產生按鈕效果。

<td style=\"background-color: red\"> // Or whatever color. 

或將TD標籤

<td><button><a href="#">BUYURL</a></button></td> 
+0

按鈕看起來不錯,我會去的 - 感謝汗先生 – sanjay 2012-04-28 05:45:41

0

爲什麼你不這樣做?

echo "<table border='0'>"; 
while($list = mysql_fetch_assoc($result)){ 
$saleprice = $list['SALEPRICE']; 
$buyurl = $list['BUYURL']; 

echo "<tr> 
    <td>$saleprice</td> 
    <td><a target='new' href='$buyurl'><b>VISIT STORE NOW</b></a></td> 
    </tr>"; 
} // end while 
    echo "</table>"; // end table since the table was constructed BEFORE the loop 

爲按鈕

<button type='button'>VISIT STORE NOW</button>

<input type='submit' value='VISIT STORE NOW'> 

或標準圖像或東西。只要確保,如果你需要使用「逃脫他們\」

+0

好主意,我的本意是把一個「按鈕」來代替簡單鏈接的「BUY NOW」 – sanjay 2012-04-28 05:36:45

1

while循環不會如預期沒有大括號的工作如下:

echo "<table>"; 
while ($list = mysql_fetch_assoc($result)) { 
    echo "<tr> 
      <td>".$list['SALEPRICE']."</td> 
      <td><a target='_new' href='".$list['BUYURL']."'>Visit Store</a></td> 
     </tr>"; 
} 
echo "</table>"; 

而不是將一個按鈕在那裏,讓錨點看起來更像一個按鈕:

<style> 
    table a { 
    font-family: "Helvetica Neue", Helvetica, Arial; 
    font-size: 13px; 
    background: #f1f1f1; 
    text-decoration: none; 
    color: #555; 
    padding: 5px; 
    border-radius: 2px; 
    box-shadow: 1px 1px 0px 0px #CCC; 
    text-shadow: 0 1px 0 #fff; 
    } 
</style> 
+0

這一個是好的,但我的本意是把一個「按鈕」來代替簡單鏈接的「BUY NOW」 – sanjay 2012-04-28 05:36:10

+1

是啊,使錨點看起來像一個按鈕更好。 – 2012-04-28 05:37:11

+0

@sanjay使用錨,這就是它的存在了。使用CSS來設置它的樣式(使它看起來像一個按鈕)。這樣,視障者如果需要的話,仍然可以覆蓋你的錨點樣式,等等。 – Sampson 2012-04-28 05:40:11

相關問題