0

When I am trying to list all the employee names from the database to assign a job for a particular person in the dropdown box. The Output value only show the initial or the First name of Employee. The other names of the employee (Last names) are not posted in the php.

Actually the names after first spaces are missing.

Here is my code...

<pre>
<tr>
<td><label>Assigning To</label></td><td><label>:</label></td>
<td>
<?php
 $result = mysqli_query($conn, "SELECT * FROM userdetails WHERE UserGroup='DigitizationArtist' || UserGroup='DigitizationArtistQC' || UserGroup='GraphicArtist' || UserGroup='GraphicArtistQC')");
 echo "<select name='ArtistName' value=''>";
 echo "<option value=''></option>";
 while($r = mysqli_fetch_array($result))
 {
 echo "<option value=" .$r['Name'] .">".$r['Name']. "</option>"; 
 }
 echo "</select>";
?>
</td>
</tr>
<pre>

This is the getting value php code...

 $ArtistName = mysqli_real_escape_string($conn, $_POST['ArtistName']);

I am getting the out for "S Gowri Shankar" is "S" I am getting the out for "Selva Kumar" is "Selva"

Please advise. What is wrong in these coding? Else the php always ignore the space after text in checkbox values.

Vijay
  • 93
  • 1
  • 2
  • 8
  • what are you saying `checkbox values`? there is no checkbox on your question. There is also no `$ArtistName` being used. and FYI: there are no `value=''` on ` – Kevin Sep 03 '14 at 06:17

1 Answers1

0

You value attributes has missing closing quotes:

echo "<option value=" .$r['Name'] .">".$r['Name']. "</option>";

Should be:

echo "<option value='" .$r['Name'] ."'>".$r['Name']. "</option>";
                    ^                ^

And also use htmlspecialchars for those values with quotations so that they wont mess up the closing on the attributes:

$ArtistName = mysqli_real_escape_string($conn, $_POST['ArtistName']);
$ArtistName = htmlspecialchars($ArtistName, ENT_QUOTES);
Kevin
  • 41,694
  • 12
  • 53
  • 70