1

I want to display data in database in table form. I wrote the following code

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['EmpID'] . "</td>";
echo "<td>" . $row['EmpName'] . "</td>";
echo "<td>" . $row['Designation'] . "</td>";
echo "<td>" . $row['Salary'] . "</td>";
echo "<td><a href='upasg3.php?empid='". $row['EmpID'] .">Edit</a ></td>";
echo "<td><a href='upasg3.php?empid='". $row['EmpID'] .">Delete</a ></td>"; 
echo "</tr>";
}

But i dont get the value of $row['EmpID'] concatenated with the value of href. It redirects to the upasg3.php with empid= blank. how to fix this? Please help

2
  • 1
    Is this line blank as well: echo "<td>" . $row['EmpID'] . "</td>"; ? Commented May 17, 2012 at 9:51
  • @user1400633 accept the correct answer please. Commented May 17, 2012 at 10:29

5 Answers 5

4
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['EmpID'] . "</td>";
echo "<td>" . $row['EmpName'] . "</td>";
echo "<td>" . $row['Designation'] . "</td>";
echo "<td>" . $row['Salary'] . "</td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Edit</a ></td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Delete</a ></td>"; 
echo "</tr>";
}

quotes.

Sign up to request clarification or add additional context in comments.

Comments

2

Try removing the single quotes after empid=

And putting them here like this:

echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Edit</a ></td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Delete</a ></td>"; 

This will give you an output like:

<a href='upasg3.php?empid=100'>

Comments

1

Try

echo "<td><a href='upasg3.php?empid=". $row['EmpID']."'>Edit</a ></td>";
                                    ^                 ^

Comments

1
 <table width="100%" border="1">
  <tr>
 <td>ID</td>
<td>NAME</td>
<td>Designation</td>
<td>Salary</td>
<td>Edit</td>
  <td>Delete</td>
</tr>
<tr>
  <td><?=$row['EmpID']?></td>
<td><?=$row['EmpName']?></td>
<td><?=$row['Designation']?></td>
<td><?=$row['Salary']?></td>
<td><a href="upasg3.php?empid=<?=$row['EmpID']?>">Edit</a></td>
 <td><a href="upasg3.php?empid=<?=$row['EmpID']?>">Delete</a></td>
 </tr>

Comments

-1

try this

echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Edit</a ></td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Delete</a ></td>"; 

Your quotes were in wrong place.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.