lukep11a Posted January 17, 2011 Share Posted January 17, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/224766-click-image-to-reveal-dynamic-content-help/ Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 Can we see all the relevant code? What part are you stuck on? Quote Link to comment https://forums.phpfreaks.com/topic/224766-click-image-to-reveal-dynamic-content-help/#findComment-1161038 Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 I deleted your other topic. Please do not double post, it wastes peoples' time. Quote Link to comment https://forums.phpfreaks.com/topic/224766-click-image-to-reveal-dynamic-content-help/#findComment-1161040 Share on other sites More sharing options...
lukep11a Posted January 17, 2011 Author Share Posted January 17, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/224766-click-image-to-reveal-dynamic-content-help/#findComment-1161042 Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 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 "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/224766-click-image-to-reveal-dynamic-content-help/#findComment-1161044 Share on other sites More sharing options...
lukep11a Posted January 17, 2011 Author Share Posted January 17, 2011 Thanks I will give this a try Quote Link to comment https://forums.phpfreaks.com/topic/224766-click-image-to-reveal-dynamic-content-help/#findComment-1161045 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.