| | |
Cutting amount of work and loading time?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
•
•
Join Date: Apr 2008
Posts: 39
Reputation:
Solved Threads: 1
Hi There
I have a very simple web gallery in php and mysql. I have noticed upon creating it, that I have several fields in my database contacting the same information (to a certain extent) and I wondered whether this would eventually put a strain on my server. Would it be possible to marry two or more of the columns together in the php coding to produce the same result?
It also seems daft spending time putting the same info into the database over and over again.
My database currently looks like this: http://www.equinefocus.co.uk/sampledatabase.jpg - however, this has not yet had the main image url included, which would look like the thumb field, but without the /thumbs/ directory included.
For example:
Each photo has a reference number, which consists of:
COLOR="red"]date[/COLOR] and an image number
i.e. 2008-04-13-001
Each thumbnail consists of:
directory path + date + /thumbs/ + image number + file extension
i.e. /photos/eventing/2007-09-01/thumbs/001 .jpg
For the thumbnail, would it be possible to pull the directory path, date, image number from the database, have the file extension and /thumb/ section in the php code, and have all elements join together to form the link to the image? It would mean that some of the content is being used more than once (date appears in the url to the image and the reference number displayed underneath).
My current code to produce the image is:
Bit complex, sorry! Any assistance would be appreciated.
I have a very simple web gallery in php and mysql. I have noticed upon creating it, that I have several fields in my database contacting the same information (to a certain extent) and I wondered whether this would eventually put a strain on my server. Would it be possible to marry two or more of the columns together in the php coding to produce the same result?
It also seems daft spending time putting the same info into the database over and over again.
My database currently looks like this: http://www.equinefocus.co.uk/sampledatabase.jpg - however, this has not yet had the main image url included, which would look like the thumb field, but without the /thumbs/ directory included.
For example:
Each photo has a reference number, which consists of:
COLOR="red"]date[/COLOR] and an image number
i.e. 2008-04-13-001
Each thumbnail consists of:
directory path + date + /thumbs/ + image number + file extension
i.e. /photos/eventing/2007-09-01/thumbs/001 .jpg
For the thumbnail, would it be possible to pull the directory path, date, image number from the database, have the file extension and /thumb/ section in the php code, and have all elements join together to form the link to the image? It would mean that some of the content is being used more than once (date appears in the url to the image and the reference number displayed underneath).
My current code to produce the image is:
PHP Syntax (Toggle Plain Text)
<?php // Connects to your Database mysql_connect("*****", "*****", "*****") or die(mysql_error()); mysql_select_db("*****") or die ("Unable to connect to MySQL"); $data = mysql_query("SELECT * FROM `others` WHERE date = '2008-04-27' AND ref ='2008-04-27-001'") or die ("No data available, please contact the site admin describing where you found this error message."); ?> <table cellpadding="2" width="65%"> <?php while($info = mysql_fetch_array($data)) { ?> <tr><td> <img src="<?php echo $info['full'];?>" border="0"</a></td></tr> <tr><td> <span class="refno">Photo Reference: <?php echo $info['ref']; ?></span></td></tr> <tr><td> <?php echo $info['info']; ?></td></tr> </table>
Bit complex, sorry! Any assistance would be appreciated.
Last edited by Borderline; May 16th, 2008 at 6:31 pm.
merge thumb and url into image - colunm just contains name e.g 1.jpg
your ref seems to be primary key and date. if true, get rid of ref.
your ref seems to be primary key and date. if true, get rid of ref.
PHP Syntax (Toggle Plain Text)
// images $big_image='/photos/eventing/'.$info['date'].'/'.$info['image']; $thumb='/photos/eventing/'.$info['date'].'/thumbs/'.$info['image']; // ref $ref = $info['date'].'-'.$info['primary_id']; // mysql $data = mysql_query("SELECT * FROM `others` WHERE date = '2008-04-27' AND primaryid ='1'")
•
•
Join Date: Apr 2008
Posts: 39
Reputation:
Solved Threads: 1
Thanks, glad to know it is possible, can save a lot of time.
End result is: http://www.equinefocus.co.uk/test_page.php - what errors have I made calling the info from the database?
PHP Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <head><link rel="stylesheet" type="text/css" href="http://www.equinefocus.co.uk/style/20080512.css"/></head> <html><body> <?php $page_title='Equine Focus'; include($_SERVER['DOCUMENT_ROOT'].'/style/20080512photography.php');?> <div id="main"> <center> <div class="pagination"> <ul> <li><a href="/photos/other/2008-04-27/page01.php">Return to album</a></li> </ul> </div> <?php // Connects to your Database mysql_connect("*****", "*****", "*****") or die(mysql_error()); mysql_select_db("*****") or die ("Unable to connect to MySQL"); // images $big_image='/photos/eventing/'.$info['date'].'/'.$info['image']; $thumb='/photos/eventing/'.$info['date'].'/thumbs/'.$info['image']; // ref $ref = $info['date'].'-'.$info['ref']; // mysql $data = mysql_query("SELECT * FROM `eventing` WHERE date = '2008-04-13' AND ref ='080'") or die ("No data available, please contact the site admin describing where you found this error message."); ?> <table cellpadding="2" width="65%"> <?php while($info = mysql_fetch_array($data)) { ?> <tr><td> <img src="<?php echo $info['$big_image'];?>" border="0"</a></td></tr> <tr><td> <span class="refno">Photo Reference: <?php echo $info['$ref']; ?></span></td></tr> <tr><td> <?php echo $info['info']; ?></td></tr> </table> <?php } ?> </table> </div></center> </html></body>
End result is: http://www.equinefocus.co.uk/test_page.php - what errors have I made calling the info from the database?
the $info['$big_image'] is not from db it is a set varible so it should be echo $big_image and same with $info['ref'] - echo $ref;
the image and ref should go below db query to get info also
the image and ref should go below db query to get info also
PHP Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <head><link rel="stylesheet" type="text/css" href="http://www.equinefocus.co.uk/style/20080512.css"/></head> <html><body> <?php $page_title='Equine Focus'; include($_SERVER['DOCUMENT_ROOT'].'/style/20080512photography.php');?> <div id="main"> <center> <div class="pagination"> <ul> <li><a href="/photos/other/2008-04-27/page01.php">Return to album</a></li> </ul> </div> <?php // Connects to your Database mysql_connect("*****", "*****", "*****") or die(mysql_error()); mysql_select_db("*****") or die ("Unable to connect to MySQL"); // mysql $data = mysql_query("SELECT * FROM `eventing` WHERE date = '2008-04-13' AND ref ='080'") or die ("No data available, please contact the site admin describing where you found this error message."); ?> <table cellpadding="2" width="65%"> <?php while($info = mysql_fetch_array($data)) { // images $big_image='/photos/eventing/'.$info['date'].'/'.$info['image']; $thumb='/photos/eventing/'.$info['date'].'/thumbs/'.$info['image']; // ref $ref = $info['date'].'-'.$info['ref']; ?> <tr><td> <img src="<?php echo $big_image; ?>" border="0"</a></td></tr> <tr><td> <span class="refno">Photo Reference: <?php echo $ref; ?></span></td></tr> <tr><td> <?php echo $info['info']; ?></td></tr> </table> <?php } ?> </table> </div></center> </html></body>
![]() |
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: Updating required 2 Clicks of the same button
- Next Thread: creating dynamic columns and rows with data
| Thread Tools | Search this Thread |
.htaccess apache api array autocomplete beginner binary body broken cakephp class cms code convert cron curl database dataentry date date/time display duplicates dynamic ebooks email emptydisplayvalue error execute explodefunction file firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include ip javasciptvalidation javascript joomla keywords limit link login mail matching mediawiki menu methods multiple mycodeisbad mysql network number object oop paypal pdf php phpincludeissue query random recursive redirect remote script search securephp server sessions shot source sp space speed sql subdomain subscription system table tag tutorial tutorials upload url validator variable vbulletin video web white youtube





