www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-04-2009, 05:59 PM
    Yokiest Yokiest is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 9
    Incrementing values

    I'm new to php and i just know the basics right now and what i'm trying to do is create a gallery which I've done successfully the only problem is that there are only 15 images and you will have the ability to comment on them but the comment program i have post to the page and i dont have 16 images is there a way i can make it go from 15 back to 1

    also the pages are set up like this

    index.php?images=1

    i need the image variable to go from 15 back to 1

    Last edited by Yokiest; 11-04-2009 at 06:50 PM.
    Reply With Quote
      #2  
    Old 11-04-2009, 08:00 PM
    kaafmim's Avatar
    kaafmim kaafmim is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 32
    put this right after were you add to image number(replace image_num with the name of your variable for image numbers):

    if ($image_num==16) $image_num=1;

    Reply With Quote
      #3  
    Old 11-04-2009, 10:02 PM
    Sodbuster Sodbuster is offline
    User Registered
     
    Join Date: Oct 2008
    Posts: 150
    Just for safety's sake, use ">", rather than "==". For instance, if you test for equality to 16 and some joker requests "index.php?image=17" you'd be in trouble. In other words, don't test for a single number, test to see if the image number is out of the proper range; if it is, reset.
    PHP Code:
    $image_count = 15;
    $image_num = (integer) $_GET['images'];
    if ((
    $image_num > $image_count) || ($image_num < 1)) {
        
    $image_num = 1;
    }

    Last edited by Sodbuster; 11-04-2009 at 10:17 PM.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    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 Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 07:15 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.