Reply
Products Coming From MYSQL...
Old 01-06-2006, 09:52 PM Products Coming From MYSQL...
Brian07002's Avatar
Defies a Status

Posts: 1,824
Name: ...
Location: ...
Trades: 0
Hi all,

I have a page that contains some sql code (query) that display's a random product from my mysql database right? Now, I have it laid out so that I have multiple categories coded so my page seems to take forever to display these products...Will someone have a look at my code to see if something can be done to speed up the load time?

Ex:
Code:
http://www.electronics.brothersvarietystore.com/
You will find this is the layout through out my sub-domain index pages. I would appreciate an idea to speed up the php code or is there some-thing in my PhpmyAdmin that I can do to speed up the load time of this script?

Ps: If the script is required for me to post, I will do so, please let me know.

Tia,
-Brian
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 01-07-2006, 01:44 AM
vangogh's Avatar
Post Impressionist

Posts: 9,845
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I'm not sure if I can help, but I will definitely need to see the code to know one way or the other. I did take a look at the site and see what you mean about it loading very slowly.

I'll be happy to take a look at your code if you post it. Hopefully I (or someone else) can help after seeing it.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 01-07-2006, 06:03 AM
chrishirst's Avatar
Super Moderator

Posts: 26,544
Location: Blackpool. UK
Trades: 0
The problem looks to be in the script that generates the thumbnail images. {/scripts/displaythumb.php}
The page loads quickly but then each of images takes several seconds to appear.

There still seems to be a problem with the server (possibly MIME types) where if a link to a PHP extension is clicked I get a save/open dialog, if I take out the page reference and just leave the querystrings in place I get a corrupted page appearing
http://www.brothersvarietystore.com/electronics/shop/?p=product&id=846&parent=19

Tried on three different machines and 6 different browsers all show the same problem
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | Crowded Nightclub? | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-07-2006, 10:59 AM
Brian07002's Avatar
Defies a Status

Posts: 1,824
Name: ...
Location: ...
Trades: 0
Hi Chris,

The code below auto generates the product thumbnail before displaying the product to the page:

Code:
<?

/* ...check size ratio and set appropriate dimensions for the thumbnail */
  $src_url = $_GET['image'];
  $filetype = substr($src_url,-4);
  if($filetype != '.jpg') exit;
  $sizelimit = 185;
  $size=getimagesize($src_url);
  $src_width=$size[0];
  $src_height=$size[1];
  $ratio=($src_width/$src_height);
  if ($ratio >= 1) {
    $dest_width=$sizelimit;
    $dest_height=($sizelimit/$ratio);
  }
  elseif ($ratio < 1) {
    $dest_height = $sizelimit;
    $dest_width=($sizelimit*$ratio);
  }

/* ... make the thumbnail and save it to $thumb_dir */
  $src_img = imagecreatefromjpeg($src_url);
  $dst_img = imagecreatetruecolor($dest_width,$dest_height);
  imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
  header("Content-type: image/jpeg");
  imagejpeg($dst_img,'',80);
  imagedestroy($src_img);
  imagedestroy($dst_img);

?>


The following query connects to my electronics database and selects the product

Code:
<?

mysql_connect ('host', 'user', 'pass') ;
mysql_select_db ('db'); 


$num_displayed = 1 ;
$category = 'category' ;

// Select random rows from the database
$result = mysql_query ("SELECT
products.pid,products.cid,products.title,products.image_url,catalog.name
FROM catalog LEFT JOIN products on products.cid=catalog.cid WHERE
catalog.cid = $category  OR catalog.parent = $category  ORDER BY RAND()
LIMIT $num_displayed;");

// For all the rows that you selected
while ($row = mysql_fetch_array($result)) 

{

echo "<a href=\"http://www.brothersvarietystore.com/electronics/shop/index.php?p=product&id=" . $row["pid"] ."&parent=" . $row["cid"] . "\"> <img src=\"scripts/displaythumb.php?image=" . $row["image_url"] . "\" border=1 alt=\"" . $row["title"] . "\">
<br>
$row[title]
</a>" ;
}

?>
Thank you again for your time,
-Brian
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 01-07-2006, 11:19 AM
Brian07002's Avatar
Defies a Status

Posts: 1,824
Name: ...
Location: ...
Trades: 0
Hi,

Just checked my server's cpanel, and under MIME Types I have:

Code:
User Defined Mime Types 
System Defined Mime Types 

application/andrew-inset ez  
application/mac-binhex40 hqx  
application/mac-compactpro cpt  
application/msword doc  
application/octet-stream bin dms lha lzh exe class  
application/oda oda  
application/pdf pdf  
application/postscript ai eps ps  
application/smil smi smil  
application/vnd.mif mif  
application/vnd.ms-excel xls  
application/vnd.ms-powerpoint ppt  
application/vnd.wap.wbxml wbxml  
application/vnd.wap.wmlc .wmlc wmlc  
application/vnd.wap.wmlscriptc .wmlsc wmlsc  
application/x-bcpio bcpio  
application/x-cdlink vcd  
application/x-chess-pgn pgn  
application/x-cpio cpio  
application/x-csh csh  
application/x-director dcr dir dxr  
application/x-dvi dvi  
application/x-futuresplash spl  
application/x-gtar gtar  
application/x-hdf hdf  
application/x-httpd-php .php3 .php .php4 .phtml  
application/x-httpd-php-source .phps  
application/x-javascript js  
application/x-koan skp skd skt skm  
application/x-latex latex  
application/x-netcdf nc cdf  
application/x-pkcs7-crl .crl  
application/x-sh sh  
application/x-shar shar  
application/x-shockwave-flash swf  
application/x-stuffit sit  
application/x-sv4cpio sv4cpio  
application/x-sv4crc sv4crc  
application/x-tar .tgz tar  
application/x-tcl tcl  
application/x-tex tex  
application/x-texinfo texinfo texi  
application/x-troff t tr roff  
application/x-troff-man man  
application/x-troff-me me  
application/x-troff-ms ms  
application/x-ustar ustar  
application/x-wais-source src  
application/x-x509-ca-cert .crt  
application/zip zip  
audio/basic au snd  
audio/midi mid midi kar  
audio/mpeg mpga mp2 mp3  
audio/x-aiff aif aiff aifc  
audio/x-pn-realaudio ram rm  
audio/x-pn-realaudio-plugin rpm  
audio/x-realaudio ra  
audio/x-wav wav  
chemical/x-pdb pdb  
chemical/x-xyz xyz  
image/bmp bmp  
image/gif gif  
image/ief ief  
image/jpeg jpeg jpg jpe  
image/png png  
image/tiff tiff tif  
image/vnd.wap.wbmp .wbmp wbmp  
image/x-cmu-raster ras  
image/x-portable-anymap pnm  
image/x-portable-bitmap pbm  
image/x-portable-graymap pgm  
image/x-portable-pixmap ppm  
image/x-rgb rgb  
image/x-xbitmap xbm  
image/x-xpixmap xpm  
image/x-xwindowdump xwd  
model/iges igs iges  
model/mesh msh mesh silo  
model/vrml wrl vrml  
text/css css  
text/html .shtml html htm  
text/plain asc txt  
text/richtext rtx  
text/rtf rtf  
text/sgml sgml sgm  
text/tab-separated-values tsv  
text/vnd.wap.wml .wml wml  
text/vnd.wap.wmlscript .wmls wmls  
text/x-setext etx  
text/xml xml  
video/mpeg mpeg mpg mpe  
video/quicktime qt mov  
video/x-msvideo avi  
video/x-sgi-movie movie  
x-conference/x-cooltalk ice
...And under Apache Handlers, I have:

Code:
Extension(s)  Handler   
      
 .html    
User Defined Handlers 
.html  application/x-httpd-php 
System Defined Handlers 
.cgi .pl .sh cgi-script 
.shtml server-parsed
Hth,
-Brian
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 01-07-2006, 06:17 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You could get your thumbnail code to save the thumbnail to a file - then in future it can check if the thumbnail exists and display it straightaway instead of endlessly resampling images on ever page load. If the thumbnail is not there, you can generate one the way you do now - this would be useful if you added a bunch of new products - the first page load would be slow as it generated the new thumbnails but they would be faster after tha.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Scribble Pad MOD for phpBB (aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 01-07-2006, 07:03 PM
Brian07002's Avatar
Defies a Status

Posts: 1,824
Name: ...
Location: ...
Trades: 0
Hi Oberon,

Do ya have sometime to work a sample out for me? I didn't see anything on
Code:
http://www.php.net/
relating to saving the thumbnail to a file.

P.s: How much of a difference would that be as far as loading time? Would it be a notable difference from what it is now? What might be the results.

On a 1-10 scale ( 10 being the fastest ) what would you say the thumbnails would load at compared to how they are now?

Thank you!
-Brian

Last edited by Brian07002; 01-07-2006 at 07:29 PM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 01-09-2006, 12:16 AM
Brian07002's Avatar
Defies a Status

Posts: 1,824
Name: ...
Location: ...
Trades: 0
Hi,

Just wondering if anyone has come up with a solution to this ^^ slow loading problem. Has anyone found the solution?

Tia,
-Brian
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 01-09-2006, 06:29 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
For saving thumbnail files, use :

imagejpeg (or imagegif or imagepng or whatever)

(PHP 3 >= 3.0.16, PHP 4, PHP 5)
imagejpeg -- Output image to browser or file
Description
bool imagejpeg ( resource image [, string filename [, int quality]] )

So to save to a file just say imagejpeg($dst_img,"thumbs/$src_url",80);

Then later you can check if the file "thumbs/$src_url" exists, and if it does, output an <img> tag with the thumbnail in it. If not you can generate a new one as before.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Scribble Pad MOD for phpBB (aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 01-18-2006, 09:13 PM
Brian07002's Avatar
Defies a Status

Posts: 1,824
Name: ...
Location: ...
Trades: 0
Hi Oberon,


Sorry for the long reply, I have been busy doing some work out of town.

Quote:
For saving thumbnail files, use :

imagejpeg (or imagegif or imagepng or whatever)

(PHP 3 >= 3.0.16, PHP 4, PHP 5)
imagejpeg -- Output image to browser or file
Description
bool imagejpeg ( resource image [, string filename [, int quality]] )
Quote:
So to save to a file just say imagejpeg($dst_img,"thumbs/$src_url",80);

Then later you can check if the file "thumbs/$src_url" exists, and if it does, output an <img> tag with the thumbnail in it. If not you can generate a new one as before.
If you or anyone with some free time would be kind enough to help me add that php code to my script, I would appreciate it very much.

Thank you,
-Brian
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 01-31-2006, 10:12 PM
Brian07002's Avatar
Defies a Status

Posts: 1,824
Name: ...
Location: ...
Trades: 0
Just wondering if anyone is getting that save dialog from my site anymore? I noticed when I went to someone elses computer, I got that problem, but not If I am on my home computer.

That's odd?!?
Does anyone know a solution to solve it???

Tia;
-Brian
Brian07002 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Products Coming From MYSQL...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12035 seconds with 13 queries