只有第一个字填充提交按钮上的值字段 [英] Only first word populating the value field on a submit button
问题描述
$ query =select member from members where active = 1名按顺序;
如果我做一个简单的话:
while($ row = $ rs-> fetch_assoc()){
echo $ row ['name']。< br> ;;
}
我得到一个清单:
Mary123
JOE
罗伯特表
然而,如果我:
< table>
$ column = 0;
while($ row = $ rs-> fetch_assoc()){
if($ column == 0){
echo< tr>;
}
echo'< td class ='cellnopad'>< input type ='submit'class ='submitbtn'name ='name'value =。$ row ['name']。> < / td>;
$ column ++;
if($ column> = 5){echo< / tr>;
$ row ++;
$ column = 0;
}
}
echo< / table>;
我的按钮看起来像
Mary123
JOE
Robert
您可以看到名称表
从名称中删除,只显示 Robert
的值。
I最初以为这个名字没有被显示,因为文本的大小与按钮大小有关,但我已经证明,通过删除 CSS
并检查 $ _POST
在个人.php
上的值。另外,如果我将数据库中的名称更改为 Robert_Tables
它工作的很好。
有什么我做错了吗?我需要改变什么才能让值显示两个单词和空间?
您的问题依赖于您忘记引用值
参数用引号''
输入。在这里看到:
value =。$ row ['name']。>
当它改为:
value ='。$ row ['name']。'>
这就是打破你生成的 html
标记,请参阅下面的简单代码段,了解如何在省略引号时处理输出:
< input type ='submit'class ='submitbtn 'name ='name'value = asd asd>< input type ='submit'class ='submitbtn'name ='name'value =asd asd>
I am doing a query and populating buttons with the results:
$query="select name from members where active=1 order by name";
If I do a simple:
while($row = $rs->fetch_assoc()) {
echo $row['name']."<br>;
}
I get a list:
Mary123
JOE
Robert Tables
However if I :
<table>
$column = 0;
while($row = $rs->fetch_assoc()) {
if ($column == 0) {
echo "<tr>";
}
echo "<td class='cellnopad'><input type='submit' class='submitbtn' name='name' value=".$row['name']."> </td>";
$column++;
if ($column >= 5) {echo "</tr>";
$row++;
$column=0;
}
}
echo "</table>";
My buttons look like
Mary123
JOE
Robert
As you can see the name Tables
gets dropped from the name and only the value of Robert
is shown.
I initially thought the name wasn't being displayed due to the size of the text versus button size, but I have proved that is not the case by removing the CSS
and checking the $_POST
value on individuals.php
. Also,if I change the name in the database to Robert_Tables
it works fine.
Is there something I am doing wrong? What do I need to change to get the value to show both words and the space?
Your problem relies on the fact that you forgot to quote the value
parameter of the input with quotes ''
. See here you have:
value=".$row['name'].">
when it should instead be:
value='".$row['name']."'>
And that is breaking your generated html
markup, see simple snippet below on how the output is handled when you omit the quotes:
<input type='submit' class='submitbtn' name='name' value=asd asd>
<input type='submit' class='submitbtn' name='name' value="asd asd">
这篇关于只有第一个字填充提交按钮上的值字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!