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
186 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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