Jump to content

Recommended Posts


$sql = "select satisfaction_id,satisfaction_type from satisfaction_type order by satisfaction_id";

$result = mysqli_query($db,$sql);

while ($row=mysqli_fetch_array($result,MYSQLI_ASSOC))

{ echo ("<tr><td>$row[satisfaction_type]</td>");

echo (' <td width="20"><a href="http://localhost/IC/satisfactioneditform.php?id=$row[satisfaction_id]">

<img src="images/Clipboard 3.png" width="20" height="20" title="Edit" border="0" /></a></td>');

echo (' <td width="20"><a href="http://localhost/IC/satisfactiondelete.php?id=$row[satisfaction_id]">

<img src="images/Close - Cancel 1.png" width="20" height="20" alt="" title="Delete" border="0" /></a></td></tr>');

}

Need some help with the passing the value of $row[satisfaction_id] to the next php page. at present all im getting is the actual text for id as "$row[satisfaction_id" as apposed to the actual value which is a integer.

 

The problem as I see it is the double quotes is probably stopping the variable being evaulated. so im geting just the variable name rather than the value . complex quoting issue  had to use single quotes for the echo statement to get around the double quotes used in the html tag options.

 

Thanks in advance.

Edited by Lawlssbatmbl

variables within double quotes are evaluated, variables within single quotes are not.  Please use code tags to enclose your code when posting in the forum.

 

you are using single quotes for your echo's and as such nothing within them will be evaluated, it is a forced string literal.  you can either concatenate the string by doing something like:

 

echo '<a href="./folder/subfolder/file.ext?id='.$row['satisfaction_id'].'">click here</a>';

or use only double quotes and escape the ones that you want to remain in the string :

 

echo "<a href=\"./folder/subfolder/file.ext?id={$row['satisfaction_id']}\">click here</a>";

 

You will see in the second option that the array reference is wrapped in curly braces - this is deliberate

Thanks Alot , that solved my issue.

 

Got really confusing using double quotes as I have a td and img tags that use double quotes and wasnt sure if I had to escape them all out .

echo " <td width="20"><a href="./filename.php?id=$rows['name']"><img src="filename" width="16" height="16" /> </a></td> "
echo " <td width=\"20\"><a href=\"./filename.php?id={$rows['name']}\"><img src=\"filename\" width=\"16\" height=\"16\" /> </a></td> "

is the second one correct if using double quotes?

yeah, the second one looks good at a glance (assuming you want to send the value of $row['name'] as the $_GET['id'] variable to the next page), the code highlighter seems to like it aswell, just remember your semi-colon at the end.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.