Jump to content

Click image to reveal dynamic content help?


lukep11a

Recommended Posts

Hi, I currently have this code which displays text on clicking the image:

 

<a href="javascript:;" onclick="document.getElementById('text').style.display='block';window.open('url...');"><img src="image..."></a>

<div id="text" style="display:none;">

...text to be displayed here

</div>

 

it works fine but I want to integrate this with php which is where I am struggling.

 

I have a mySQL database with 4 fields (id;name;description;url), what i would like to do is name the div to be opened on click with the 'id' field from the database so that it would become '<div id="id"> and then more than one function could be implemented on each page. I would also like to replace '...text to be displayed here' with the field 'name' from the database and '...url' with the field 'url from the database.

 

Any help would be very much appreciated. Thanks in advance.

Link to comment
Share on other sites

Thanks for deleting the other one, thats what I was trying to do!

 

Mainly the part where the div id takes its name from the id field in the database, I know how to get specify the variable in the database:

 

$id = $row{"id"};

 

but do you know how I would integrate that with the previous html code?

Link to comment
Share on other sites

Thanks for deleting the other one, thats what I was trying to do!

 

No problem.  You are not allowed to delete your own posts.

 

Mainly the part where the div id takes its name from the id field in the database, I know how to get specify the variable in the database:

 

$id = $row{"id"};

 

but do you know how I would integrate that with the previous html code?

 

PHP is a scripting language and very easily integrates with HTML.  In fact, that's ultimately what PHP produces.  If you want to use the $id variable in the HTML you would simply do:

 

echo "
...text to be displayed here
";
?>

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.