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
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
migrating to phpbb forum from vBulletin 4.2 3 41
Video Tutorial help 2 40
web page freezes after ajax post 7 53
Diff of the day 2 10
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

730 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