开发者

Sending a PHP GET to another page not working

I am trying to send a simple get to another page, and it doesn't send the correct info. I am pulling my id from mySQL, and its turning into a variable, which is $id. I am echoing a开发者_开发技巧 button so a user can click on the button and learn more about the item.

Here is my echo.

    echo "<td width='120' align='middle'><a href='info.php?id='" . $id . "'><input              
    class='btn' style='font-family:Helvetica' type='submit' value='Info'></a></td>";

If I simply say echo $id; it shows '30' which it's supposed to. But pushing it using the echo above doesn't work. So I tried adding a hidden text field and submitting that. If I do that, it doesn't add on the id=, it just puts in the URL info.php?30= instead of info.php?id=30

Any ideas?


You have an extra ' in the href parameter which may be causing problems. Change it to:

<a href='info.php?id=" . $id . "'>
                     ^--- extra ' was here


You have an unnecessary single quote after id=. The browser probably tries to automatically fix the error and removes the id in the process.


Try this

echo "<td width='120' align='middle'><a href='info.php?id=" . $id . "'><input
class='btn' style='font-family:Helvetica' type='submit' value='Info'></a></td>";


Remove the single-quote ' after id:

echo "<td width='120' align='middle'><a href='info.php?id=" . $id . "'><input class='btn' style='font-family:Helvetica' type='submit' value='Info'></a></td>";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜