Consider the following code:

while($row=mysql_fetch_assoc($result)){
                echo
                '<tr> ';
                echo    '<td><a href="#?id='.$row['id'].'" class="dep_link"><img src="images/icn_edit.png" title="Edit"></a>&nbsp;<a href="#"><img src="images/icn_trash.png" title="Trash"></a></td>';

In my php form, i have created a jquery dialog link such that when the user clicks the 'icn_edit.png' image , a new iframe is loaded with fields for update. i want to pass the 'id' variable from the link of that particular html table row to the division of html where the iframe is created so that i can use it as key for querying database. apparently, the iframe loads but the 'id' is not displayed in the test textfield.

how can i post the variable/value ie. the 'id'. the code works when i replace the '#' with an external file but not when i intend to pass it to a html div.

Member Avatar for diafol

I'm a little confused as to what you're trying to do. Are you using the anchor link as a hyperlink (reload page / javascript hook) or are you using it as a bookmark (due to the #...)?

In order to pass info to the iframe, I'm assuming it needs to be via querystring like:

<iframe src="http://www.example.com?id=<?php echo $id;?>"></iframe>

If you've just got the one iframe, e.g. for a videoplayer, then js could be better for changing video srcs.

commented: Nice Answer ! You beat me to it ! +5
Member Avatar for LastMitch

@mogaka

how can i post the variable/value ie. the 'id'. the code works when i replace the '#' with an external file but not when i intend to pass it to a html div.

To get the id you need to do this:

yourdomain/view.html?id=<?php echo $row['id'];?>

in your view.html there should be a query that select the id

Is this a JQuery issue? I noticed in JQuery mobile that pages are not truly loaded, and any GET vars are lost because the pages are loaded by ajax. Also this is a JQuery dialog that he is trying to pass the ID to I think.
It seems the OP already knows how to pass the variable in the URL : href="#?id='.$row['id'].'
Maybe it would be better to store the variable in a hidden input and access on the dialog page using Javascript?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.