[英]Why <a href="..." is not working?
I am new to PHP.我是 PHP 新手。 Trying to pass variable through href, but not working properly.Can someone please help TIA, here is my code:
试图通过 href 传递变量,但无法正常工作。有人可以帮助 TIA,这是我的代码:
while($rows=mysql_fetch_array($result)){
echo "<tr><td>".$rows{'bi_SKU'}.
"<td>".$rows{'bi_title'}.
"<td>".$rows{'bi_author'}.
"</td>"
"<td><a href=CopyAdd.php?SKU=".$rows{'bi_SKU'}.
您需要用引号包裹href
值 -
<a href='CopyAdd.php?SKU=".$rows{'bi_SKU'}."'
Modify your code...修改你的代码...
while($rows=mysql_fetch_array($result)){
echo "<tr><td>".$rows{'bi_SKU'}.
"<td>".$rows{'bi_title'}.
"<td>".$rows{'bi_author'}.
"</td>"
"<td><a href='CopyAdd.php?SKU=".$rows{'bi_SKU'}."'
Note: Quotes is missing....注意:引号丢失....
Modify:调整:
while($rows=mysql_fetch_array($result)){
echo "<tr><td>".$rows{'bi_SKU'}.
"<td>".$rows{'bi_title'}.
"<td>".$rows{'bi_author'}.
"</td>".
"<td><a href='CopyAdd.php?SKU=".$rows{'bi_SKU'}."'>...</a>".
you missing quotes.你缺少引号。 Try it
尝试一下
<a href='CopyAdd.php?SKU=".$rows{'bi_SKU'}."'
Try This..尝试这个..
while($rows=mysql_fetch_array($result)){
echo "<tr>
<td>".$rows{'bi_SKU'}."</td>
<td>".$rows{'bi_title'}."</td>
<td>".$rows{'bi_author'}."</td>
<td><a href='CopyAdd.php?SKU=".$rows{'bi_SKU'}."'>...</a></td>
</tr>";
}
td
& tr
tags closed, anchor
tag closed and quotes added to href
. td
& tr
标签关闭, anchor
标签关闭,引号添加到href
。 When you indent the code properly most of the syntax errors can be spotted easily.当您正确缩进代码时,可以轻松发现大多数语法错误。 Also use a good IDE to do that for you.
也可以使用一个好的 IDE 来为你做这件事。
I don't think the single quote is not the problem.我不认为单引号不是问题。
The problem is that he missed the closing anchor tag.问题是他错过了结束锚标签。
href
should work without single quotes also . href
应该在没有单引号的情况下工作。
Solution is you need to close the anchor tag first .解决方案是您需要先关闭锚标记。
"<td><a href=CopyAdd.php?SKU=".$rows{'bi_SKU'}.">...</a>".
<td>
.<td>
。<a></a>
<a></a>
<a>CLICK</a>
<a>CLICK</a>
href
is missing '
around value: <a href='#'>CLICK</a>
href
缺少'
值: <a href='#'>CLICK</a>
[]
but not via {}
(turn on error reporting to see errors).[]
而不是通过{}
(打开错误报告以查看错误)。 You can use "
and surround variable with {}
to put it safely in string.您可以使用
"
并用{}
包围变量以将其安全地放入字符串中。
while($rows = mysql_fetch_array($result)) {
echo "<tr>
<td>{$rows['bi_SKU']</td>
<td>{$rows['bi_title']}</td>
<td>{$rows['bi_author']}</td>
<td>
<a href='CopyAdd.php?SKU={$rows{'bi_SKU'}'>SKU</a>
</td>
</tr>";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.