Only the first word that populates the value field in the submit button

I make a request and populate the buttons with the results:

$query="select  name from members where active=1 order by name";

      

If I do simple:

while($row = $rs->fetch_assoc()) {
    echo $row['name']."<br>;
}

      

I am getting a list:

Mary123

JOE

Robert's 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 is Tables

stripped from the name and only the value is displayed Robert

.

Initially I thought that the name is not displayed because the text size in comparison with the size of the button, but I proved that it is not, deleting CSS

and checking the value $_POST

on individuals.php

, also if I change the name of the database on Robert_Tables

, it works fine.

Is there something I am doing wrong? What do I need to change to get the meaning to show both words and space?

+3


source to share


1 answer


Your problem is based on the fact that you forgot to specify the parameter value

for the quoted input ''

. See here:

 value=".$row['name']."> 

      

when should it be:

 value='".$row['name']."'> 

      



And it breaks your generated markup html

, see the simple snippet below for 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">
      

Run codeHide result


+4


source







All Articles