![]() |
How to load data from database into jquery modal box
I have been faced with this problem for a few days i have this script that retrieves data from the database and display it to the user but i want to load this database in jquery modal box please assist anyone:
Script that gets data from database: PHP Code:
|
gazaian1 you have left a lot of needed information out of this post, like the name of the jquery modalbox you were using. So I did this using Simple jQuery Modal. You can find it here http://www.queness.com/post/77/simpl...indow-tutorial
It is easy to understand and the three components of it are listed. What I did to modify this is use ajax to preform the db query and placed the return into the <div id="dialog" class="window"> section of the html code, which means I eliminated what was originally there in the demo. Next I added an ajax section to the jquery so you could get the results of the DB query and form the contents of the <div id="dialog" class="window"> box. I am thinking that you want to have a number of cities listed and when clicked they populate the modalbox and make it appear. If so you need to add the extra cities under <a href="#dialog" name="modal">The City Name</a> and get the name of the city to pass to the php file. Here is that php file [sort of you add the db query] PHP Code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
Thanks sun fighter but when i add my php files it loads the who page and not the contents from the DB any ideas i can't give a link to the site as it is not live yet. Please help me with this:)
How can i acheive something like on this site: http://www.eversave.com/online/david-s-cookies-3 |
If you look at the php file I gave you you will see
FIRST I assign value to $row[] just like reading from a DB. THEN Set string equal to the returned $row[]. Don't use the $row['city_url'] USE variable. The heredoc section dups what is in the page I asked you to readhttp://www.queness.com/post/77/simpl...indow-tutorial. We move the contents of <div id="dialog" class="window"> and fill it in with the variables. THIS IS WHAT you might not be doing. LASTLY we echo it to the html. If you are still confused post your php file that loads the who page. |
| All times are GMT +1. The time now is 09:02 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.