Shing Ysc
Shing Ysc

Reputation: 15

Why cannot call the div #popup1?

Why cannot call the div #popup1? I want to pass the $row['staffId'] to div and call the popup to show the information .

$result = mysql_query("SELECT * FROM Staff WHERE companyId='$companyIdResult'");

echo "<div>
<table >";

while($row = mysql_fetch_array($result)){
  echo "<tr>";
  echo "<td >" . $row['staffName'] . "</td>";
  echo "<td>" . $row['staffPhone'] . "</td>";
  echo "<td><a class ='editbutton' href=' #popup1?edit_id=".$row['staffId'] ."'>Edit</a></td>";
  echo "</tr>";
}


echo "</table>";
echo "</div>";

if($_GET['edit_id'] != ""){
   $staffId = $_GET['edit_id'];

$sql2 = mysql_query("SELECT *FROM Staff WHERE staffId='".$staffId."'");
echo '<div id="popup1" class="overlay" >';
echo '<div class="popup">';
echo '<input type="text" name="staffName" value= ".$row['staffName']." ><br>';
echo '<input type="text" name="staffPhone" value=".$row['staffPhone']."><br>';
echo '</div>';
echo '</div>';
}

Upvotes: 0

Views: 43

Answers (1)

ChristianM
ChristianM

Reputation: 1823

First of all you cannot append query parameters (?edit_id=...) to an anchor like #popup1, also you seem to misunderstand how PHP and the browser interact, you cannot open a popup and create it dynamically on the server side the way you seem to plan to. You could use AJAX to load the matching form for the staffId into your popup or generate a popup for every staffId beforehand (and create matching links with different anchors), but you try to open a popup1 with values generated on the server side and that doesn't work in this way.

Upvotes: 1

Related Questions