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.

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>";

Link to comment
Share on other sites

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]."\"

Link to comment
Share on other sites

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.