Jump to content

[SOLVED] Getting a link to work with PHP and Javascript


BadGoat

Recommended Posts

Hello!

 

I have been trying to get a link to work which is in PHP but has a Java element to it.. And so far, I have not been successful.

 

<td>echo"<a href=\"http://www.domain.com/edits/edit_status.php?diw_id=\".$row[diw_id].\"\" onClick=\"openPic('edits/edit_status.php?size=small','pop','600','200'); return false\">[edit]</a></td>

 

When I mouse over the link, the edit_status.php?diw_id= is blank, not getting the ID#. Clicking the Edit pops up the new window as hoped for, just missing my data.

 

Since I am relatively new, I would bet I am doing something very wrong.

 

 

Is that the whole chunk of code, cause you do not have a closing "; in your echo .... also how are you going in and out of html to php, cause you have <td> which is html and then you go right into echo for php without a <? and a closing ?> after the php...

My fault, I selectively tried to only include the link in question.

 

Typically I use single quotes, but I run into problems (such as this one) when links have combinations of single and double quotes within them.

 

A larger chunk of code:

 

$get_firm_info = mssql_query("SELECT *  FROM i_status  WHERE status_id = '".$row['diw_status_id']."'");

$row=mssql_fetch_array($get_firm_info);

$status_name = $row['status_name'];

 

echo'

<tr>

    <td class="selcol1">Status:</td>

<td class="selcol2"> ' .$status_name. ' ';

    echo"<a href=\"http://www.domain.com/edit_status.php?diw_id=\".$row[diw_id].\"\" onClick=\"openPic('edits/edit_deposition_status.php?size=small','pop','600','200'); return false\">[edit]</a></td>

</tr>";

My fault, I selectively tried to only include the link in question.

 

Typically I use single quotes, but I run into problems (such as this one) when links have combinations of single and double quotes within them.

 

A larger chunk of code:

 

$get_firm_info = mssql_query("SELECT *  FROM i_status  WHERE status_id = '".$row['diw_status_id']."'");

$row=mssql_fetch_array($get_firm_info);

$status_name = $row['status_name'];

 

echo'

<tr>

    <td class="selcol1">Status:</td>

<td class="selcol2"> ' .$status_name. ' ';

    echo"<a href=\"http://www.domain.com/edit_status.php?diw_id=\".$row[diw_id].\"\" onClick=\"openPic('edits/edit_deposition_status.php?size=small','pop','600','200'); return false\">[edit]</a></td>

</tr>";

 

In your echo you are escaping the " before you print the variable (diw_id=\".$row[diw_id].\"\") try this

 

diw_id=\"".$row[diw_id]."\"

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.