Solved

How can i improve my site architecture so that i'm not trying to run dynamic code in a mysql db?

Posted on 2008-11-02
2
182 Views
Last Modified: 2010-04-16
Hello,

Following on from a problem related to running a php include from a mqsql database:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23862308.html#a22849649

Ahoffmann said my site contained "Ugly, very ugly code .."
and that "it's a bad idea to rerieve (php or any other) code from the database to be processed"

I would like to know what my alternatives are.

Essentially my site is comprised of Google Maps markers whose textual info is held in a database and i would like this to appear alongside photos that are held in a subfolder with the same name as the record id.

Presently i have tried to accomplish this by using the database to also hold the markup for a single image that when clicked loads all the other images from the same folder.
I ran into problems because the images are loaded by Javascript picture viewer, Highslide, and this can't read whats on the server directly so i was using PHP to do this. I included a PHP script into the database to make this idea work and that's where i ran into problems.

The Highslide forum has suggested a workaround that involves dropping the dynamic element and instead including a mini image index scipt in each folder to help load the images. (see here:)
http://highslide.com/forum/viewtopic.php?t=2600&postdays=0&postorder=asc&start=0

I would prefer to maintain a dynamic site and so i'm keen to discover how this can be done and that's where your help would be very useful - please can you explain how i might accomplish this ?


Many thanks for your ideas
0
Comment
Question by:Daniish
2 Comments
 
LVL 44

Accepted Solution

by:
scrathcyboy earned 500 total points
ID: 22862674
I hope you get lots of response to this question, because it underscores problems in PHP vs. javascript.

I think Ahoffman's dislike was embedding PHP code in a database.  What you want in the database is a set of entries that are indexed, so when you index on a pushpin, then you get (1) the text to show, (2) the thumbnail images to show, and (3) all the related links of other images to show.  This is how it should be.

The PHP code should be kept in PHP pages, and these pages do the entire assembly of all of the above, as it pulls them out of the database.  So it is the PHP code that actually puts together a complete web page for the user to see -- and part of that webpage is the javascript that runs the slide show.  

Now if you HAVE to use highslide, then you encapsulate ALL that code into a single JS file, that included in the head of the document.  Then all you need is one or two functions to start and stop the slide show, and those are merely referenced in the new Page that PHP composed and sent to the browser --

<BODY onLoad="startShow();>
Button 1 -- start slide show
Button 2 -- stop slide show.
Plus whatever other HTML in the page.

So in summary, all PHP to put the pages together in the PHP files, ALL linked data in the database, and javascript sent to the browser in the page that runs the Highslide.  I hope that helps.
0
 

Author Comment

by:Daniish
ID: 22866358
Thanks Scrathcyboy that's helpful. I will keep this question open for a while to see if anyone else has any thoughts on this because i would like to understand this better.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to create a scatter graph with straight lines 6 25
Download a website to hdd 2 47
Update from TABLE-A to TABLE-B 5 34
PHP: concatenate query 12 28
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now