2012-04-28 84 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

相关问题