2014-12-26 21 views
1

我有2个页面正在运行,并且第一页有许多单选按钮选项。例如其中的一个选项是:如何在提交表单中发送字符串或使用GET变量接收字符串

Hello World 

当我提出这第二页,并打印出的第二页上的GET变量,我得到的是

Hello 

如果我找不出第一页只发送的0数组索引,或者如果GET功能只接受0

<?php 
    while ($row = mysqli_fetch_assoc($data)) { 
     print '<td><input type="radio" name="items" value='.$row{"items"}.'>'.$row["items"].'</td>'; 
    } 
?> 
<input type="submit" value="Submit"> 
+2

'$ row {“items”}'?? – MH2K9

+1

@ user3583142 PHP现在允许Perl风格访问关联数组。 – Barmar

+0

'Hello world'发送$ _GET和您的代码PHP代码不匹配 – Riad

回答

2

你需要把周围的value属性引号如果包含空格数组索引,否则该值在空间结束。如果值包含引号,则还应该使用htmlspecialchars

print '<td><input type="radio" name="items" value="' . htmlspecialchars($row{"items"}) . '">'.$row["items"].'</td>'; 
               ^         ^
+0

是的!这固定了它。非常感谢你! – user2883071

相关问题