PHP url链接变量

时间:2013-12-15 10:34:22

标签: php dynamic hyperlink

我有以下问题。

我做了一段时间mysql_fetch_arry函数来从表中获取值。

我想在每一行,最后一个文本字段(ammount)和一个按钮(添加)。

代码如下所示:

<?php while($info = mysql_fetch_array( $data )): ?>
<td id="articlenr" class="width1left"><a href="www.google.de\<?php echo $info['articlenr'] ?>"><?php echo $info['articlenr'] ?> </a></td>
<td class="width2center"><?php echo $info['stock']. " / " .$info['minstock'] ?></td>
<?php endwhile ?>

第二行是关于文章细节,什么是有用的。

所以问题是我如何才能在按钮和每行的文本字段上执行onclick事件。

点按钮上的

应该会发生:

  1. 从textfield获得价值&#34; ammount&#34; (此行)和Articlenr(此行)
  2. 建立一个链接,其中包含#34; .... \ add.php?article = articlenr(来自此行)&amp; ammount = ammount(来自此行) 3.打开一个新窗口
  3. 感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

<?php while($info = mysql_fetch_array( $data )): ?>
<td class="width1left"><a href="www.google.de\<?php echo $info['articlenr'] ?>"><?php echo $info['articlenr'] ?> </a></td>
<td class="width2center"><?php echo $info['stock']. " / " .$info['minstock'] ?></td>
<td><input type="text" id="amount<?php echo $info['articlenr'] >?"></td>
<td><input typ="button" value="add" onclick="openWindow('<?php echo $info['articlenr'] ?>');"></td>
<?php endwhile ?>

<script>
function openWindow(articlenr) {
    var amount = document.getElementById('amount'+articlenr).value;
    var url = ".../add.php?article="+articlenr+"&ammount="+amount;
    window.open(url);
}
</script>