0

I am using the following line inside my PHP code:

echo"<td><a href='EditAdminRestaurantes.php?id=1' data-ajax='false'><img src='editicon.png' width='31' height='31'></a> </td>";

When the PHP file is called at the browser, the resulting URL is:

http://../EditAdminRestaurantes.php?id=1

What I a need is to change the value after the ?id= param, I need to put there the PHP variable `$row[0], but when I insert the code for that, then the URL is not the expected.

This is my code for that:

 echo"<td><a href='EditAdminRestaurantes.php?id='".$row[0]." data-ajax='false'><img src='editicon.png' width='31' height='31'></a> </td>";

And the resulting URL is:

http://../EditAdminRestaurantes.php?id=

Any help is welcome.`

2
  • echo $row[0]; what does it show? Commented May 31, 2014 at 3:28
  • @Harikrishnan, it shows 1. Commented May 31, 2014 at 3:29

3 Answers 3

2

You close the href attribute with a single quote before $row[0]. It needs to be closed after, like so:

echo"<td><a href='EditAdminRestaurantes.php?id=".$row[0]."' data-ajax='false'><img src='editicon.png' width='31' height='31'></a> </td>";
Sign up to request clarification or add additional context in comments.

Comments

1

I think you may need to move your single quote from before the variable to after it like so

echo"<td><a href='EditAdminRestaurantes.php?id=".$row[0]."' data-ajax='false'><img src='editicon.png' width='31' height='31'></a> </td>";

Comments

1

You have an error in the quotes. If you do it this way, it will work.

echo '<td><a href="EditAdminRestaurantes.php?id='.$row[0].'" data-ajax="false"><img src="editicon.png" width="31" height="31"></a> </td>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.