Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 03-28-2012, 06:15 AM
Junior Member
 
Join Date: 03-16-12
Posts: 7
iTrader: 0 / 0%
Recent uploaded Galleries

Code:
<?php $host = 'localhost'; $dbUser = 'username'; $dbPass = 'password'; $db = 'database'; mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error()); mysql_select_db("$db") or die(mysql_error()); $result = mysql_query("SELECT max(id)-1 as id,cat,bigimage FROM pp_photos order by id DESC LIMIT 1" ) or die(mysql_error()); while($row = mysql_fetch_array( $result )) { print "<a href=\"/images/showgallery.php?cat=" . $row['cat'] . "\"><img src=\"/images/data/" . $row['cat'] . "/thumbs/" . $row['bigimage'] . "\"></a>"; } ?>
Above script extract latest uploaded gallery link and thumb. Anyway I could extract 5 latest instead of one? Oh, if possible, a way to exclude a particular cat (category). I've tried multiple ways but failing all.

Thank you in advance
 
Reply With Quote
  #2 (permalink)  
Old 03-28-2012, 07:00 PM
DJDarkViper's Avatar
Junior Member
 
Join Date: 03-28-12
Location: Kelowna, BC, Canada
Posts: 27
iTrader: 0 / 0%
You bet!

See where you got:
$result = mysql_query("SELECT max(id)-1 as id,cat,bigimage FROM pp_photos order by id DESC LIMIT 1" ) or die(mysql_error());

use this instead:

$result = mysql_query("SELECT max(id)-1 as id,cat,bigimage FROM pp_photos order by id DESC LIMIT 5" ) or die(mysql_error());

Just updated the "LIMIT" argument in the SQL call. You already have a while loop to go through all results returned, so everything else is just fine


Have fun!
 
Reply With Quote
  #3 (permalink)  
Old 03-30-2012, 10:55 AM
Junior Member
 
Join Date: 03-16-12
Posts: 7
iTrader: 0 / 0%
Thank you, sir! it worked!
 
Reply With Quote
  #4 (permalink)  
Old 04-04-2012, 05:25 PM
TheRACK's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 08-13-10
Location: Michigan
Posts: 688
iTrader: 0 / 0%
DESC LIMIT # ^^

Glad you got the help you wanted.
__________________
Web Design, Animation, Publishing, Programming & More
QUICKTurnarounds 72HOURGURANTEED READYWhen You Are
Avizual.com Avizual.com
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with saving url of uploaded images kontrol Coding Forum 0 06-03-2011 04:20 AM
wordpress xml from 2.8.5 to be uploaded to 3.0.1 trentz Blogging Forum 3 10-19-2010 12:21 PM
File Size is 0 when uploaded M5Love Dedicated Servers 3 11-01-2007 05:37 AM
Image gets lighter when uploaded! Why? fuser00 Graphic Design Forum 2 08-20-2007 08:46 PM
Need help with newly uploaded site devilzfan300 Web Design Lobby 5 08-06-2007 10:45 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 09:55 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2014 Escalate Media




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.