0

Why the table can get $row['staffName'] but the value='.$row['staffName'].' cannot get full value?

while($row = mysql_fetch_array($result)){
      echo "<tr>";
      echo "<td >" . $row['staffName'] . "</td>";
      echo "<td>" . $row['staffPhone'] . "</td>";
      echo "<td>" . $row['staffEmail'] . "</td>";
      echo "<td>" . $row['staffName'] . "</td>";
      echo "<td>" . $row['staffName'] . "</td>";

  echo "<td style='text-align:right;'>" ;
  $staffId = $row['staffId'];

  echo "<a class ='editbutton' href='#$staffId'>Edit</a>";
  echo '<div id='.$staffId.'  class="overlayEdit" >';
  echo '<div class="popupEdit">';
  echo '<a class="closeEdit" href="#">&times;</a>';
  echo '<form name="formEdit" method="post" action="newStaff_connect.php">';
  echo '<h3>Update Staff</h3>';
  echo '<HR color="#D8D8D8" size="2" width="100%"></HR><br>';
  echo '<h5>Full Name</h5>';
  echo '<input type="text" name="staffName" value='.$row['staffName'].'><br>';
  echo '<h5>Contact</h5>';
  echo '<input type="text" name="staffPhone" value='.$row['staffPhone'].'><br>';
  echo '<h5>Email Address</h5>';
  echo '<input type="email" name="staffEmail" value='.$row['staffEmail'] .'><br>';
  echo '<input type="button" class="btn-login" value="Update" onClick="newStaffCheck()" />';
  echo '</form>';
  echo '</div>';
  echo '</div>';

  echo "</td>" ;
  echo "<td style='text-align:right;'>" ;
  echo "<a class ='editbutton' href='?delete_id=".$row['staffId']."'>Delete</a>"; 
  echo "</td>" ;
  echo "</tr>";
}
echo "</table>";
echo "</div>";

the table can get "Chan Tai Man"

but input just show the "Chan"

Shing Ysc
  • 15
  • 6
  • 1
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[this happens](https://media.giphy.com/media/kg9t6wEQKV7u8/giphy.gif)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Mar 09 '18 at 10:01

2 Answers2

1

You're missing the ":

echo '<input type="text" name="staffName" value="'.$row['staffName'].'"><br>';

Also here:

echo '<div id='.$staffId.'  class="overlayEdit" >';

Should be:

echo '<div id="'.$staffId.'"  class="overlayEdit" >';
jonas3344
  • 201
  • 1
  • 7
0

What you have:

 echo '<input type="text" name="staffName" value='.$row['staffName'].'><br>';

What it should be:

echo '<input type="text" name="staffName" value="'.$row['staffName'].'"><br>';

notice the double quotes to wrap the value= contents. notice the single quotes to end the line. The part .$row['staffName']. will concatinate and substitute that part of the line with the value of the variable $row['staffName']. And then again the last part is within single quotes again, with a double quote being the closing quote for the value-attribute's contents.

More lines are affected by this error.

Werner
  • 449
  • 4
  • 12