Redirecting a user to the first page in a recordset (PHP/MySQL)

On my site I have a comments page with a small text box to
enter a page number to navigate through the comments. If a user
enters a page number greater than the highest page, I want them to
be redirected to the first page. I'm having a lot of trouble
figuring out how to do this because the 'current page' variable is
set before the mysql query, and its not until after that, the total
'page variable' is set.
The 'total page' variable must be set after the query because
it relies on other variables from the query, and the 'current page'
variable must be set before the query because the query relies on
the 'current page' variable. So it seems impossible to rearranges
these things to put in something such as:
if ($pageNum_submission_comments >
$totalPages_submission_comments) {
$pageNum_submission_comments = 0;
Is there something else I can do? I would really appreciate
some help on this, as I've been trying to figure out how to do it
for such a long time now.
Thanks in advanced to anyone who is able to help me.

AngryCloud wrote:
> If you wouldn't mind explaining the example code you
provided, that would be
> very convenient... but if you do mind, I'm sure I can
figure it out eventually.
You need to find the number of comments associated with a
particular
article, and use that number to calculate the number of pages
they will
occupy. SELECT COUNT(*) finds the number of records in a
table. So,
something like this would find the number of comments
associated with a
specific article:
$getTotal = "SELECT COUNT(*) FROM myTable WHERE articleID =
$articleID";
You then pass that SQL query to mysql_query() to process it.
mysql_fetch_row() extracts the result as an array, which I
have assigned
to $row. Since there's only one value in the result, $row[0]
contains
the number you want.
$result = mysql_query($getTotal);
$row = mysql_fetch_row($result);
$totalComments = $row[0];
$totalComments contains the number of comments. You can now
use that
figure to calculate the maximum number of pages.
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Similar Messages

  • Getting a field value from the first page on the second page in HTML

    I have a 2 page form I'm presenting in HTML to the user. The first page they select an action, enter a USERID and click the next page button. (The button executes "xfa.host.pageDown();" on the click action at the server)
    On the initialize of the second page I try to get the value of the USERID field from the first page and create a SQL statement to open my data connection. The issue I have is that I cannot get the value of the USERID field. This code works cause if I hardcode a valid value the query works. I tried to work around this by putting the same field on page 2, but it still did not work but the field was populated with displayed. I only assume the data is not populated at the time the initialize is invoked.
    Here is my code on the initialize..
    xfa.sourceSet.nodes.item(0).resolveNode("#command.query").commandType = "text"
    xfa.sourceSet.nodes.item(0).resolveNode("#command.query").select.nodes.item(0).value = "Select * from TABLE where userid = '" + xfa.form.resolveNode("form1.Page1.txt_EmployeeLogin").rawValue + "'"
    xfa.sourceSet.DataConnetion.open()
    Any help is greatly appreciated.
    THANKS!!

    Hi Steve,
    If you haven't already done so, I recommend posting this question in the LivCycle Forms forum.
    Jared

  • How can I disable the previous button in the first page and the next button in the last page?

    Hi all,
    I have created a new skin for a webhelp by modifying the layout and the buttons. However, I am not able to find a way where in we can
    disable the previous button ini the first page of the webhelp and hte the next page in the last page of the webhelp. If both the next and previous button is visibile in the first and last page, it is sort of misguiding the user.
    I am using Robohelp 9.
    Please advice.
    Thanks,
    Parag

    I think you are mixing Previous and Next in a browse sequence and the Previous and Next that you get in the browser itself.
    In a browse sequence, they are automatically disabled at the start and finish. When in the first topic in the sequence only Next will be enabled, when in the last topic only previous will be enabled.
    Previous and Next in the browser are working on the topics your user has viewed which is not the same thing.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Anytime I try to print in Firefox a Microsoft KB article that is 1 page, I always only get the first page.

    Anytime I print any Microsoft KB article, I only get the first page worth of text. This is very troubling because the articles are typically long, and I only get 1 page. The second page always comes out blank (even though in IE it will print out multiple pages with all the text).
    My specific example today is listed in the URL below. This example will only print to the "DIR" command, I don't get the full page printed out.
    Anyone else have this problem? Anyone have a resolution? I hate having to hit up IE just to print a single article.
    I updated to FF 8.01 just to make sure, and I have tried different printers and even computers, to no avail. Even the print preview has the issue, only the first page worth of text is printed and the second page is always blank (even if there are 3, 4, 5, etc pages of data to be printed).
    I have also tried the Firefox Menu -> Print command, and the "on-page" print command. I have seen moderate success with highlighting all the text that I want to print and going to "Print-Selection" but it is ugly.
    Any feedback or assistance is greatly appreciated.

    '''Try the Firefox Safe Mode''' to see how it works there. The Safe Mode is a troubleshooting mode, which disables most add-ons.''
    ''(If you're not using it, switch to the Default theme.)''
    * You can open the Firefox 4.0+ Safe Mode by holding the '''Shift''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Don't select anything right now, just use "'Start in Safe Mode"''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shift key) to open it again.''
    '''''If it is good in the Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one.
    Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • Displaying more than the first page of a pDF

    My firm posts pdf's online for users to access. One of the Ipads in the firm can view all the pages of any document. The others only access the first page which is a problem. What's strange is that the one that can view the file's entirety does not have a PDF viewer - no Good Reader or even ibooks. Basically it's factory settings because it's user isn't very active. I've got two Ipads to compare and for anything that seems related (general and safari) the settings are the same between the one that works and one that doesn't. The one that is working is 3G and the non-working one is not. Nither is an ipad 2. (Aside - Does that make them Ipad 1?)
    What else

    Correction to my earlier post- they are both 3G so that can't really be the problem source either.

  • How do I print the first page of numerous documents?

    Computer setup:
    Adobe Acrobat Pro 9.10 on Windows XP Professional x64 Edition.
    User experience:
    I consider myself proficient in office (Excel, Word) and software use in general (Windows XP). The extent of my Adobe Acrobat experience is creating custom dynamic stamps. I have little to no javascript programming knowledge.
    Problem:
    Numerous pdf files in multiple directory locations must have the first page of each document printed.
    Current (and time-consuming) solution:
    Copy the files to a single directory
    Use Acrobat Pro to combine files and individually select the first page for each document
    Combine and print.
    Tools
    Filename Extractor (can be used to extract the filename OR filename and path of documents)
    Bonus Points
    An index of all documents exists in Excel format. Documents are selected for printing by filtering this Excel index. The Excel index will have a column containing the path of each document. A solution that can utilise this path information to shortcut the time-consuming "copy and paste" method currently used will attract bonus points.
    Thanks in advance,
    Simon

    Create a batch process the executes the following JavaScript code:
    this.print({nStart:0, bUI: false, bSilent: true});
    It will silently print the first page of any file you batch. Be careful not to overload your printer's queue by sending too many files in one go.

  • In Pages, How can I get headers and footers to show up on more than the first page of each section?

    In Mountain Lion, I considered myself a fairly expert user of Pages. Since "upgrading" to Mavericks, I can't get even basic things to work anymore. My current problem is that the headers and footers are only showing up on the first page of each section. A related annoyance is that if I copy the information in a header or footer, all the associated formatting disappears when I paste it. But the first problem is the one that matters — headers and footers that only show up on one page sort of negate the whole point of headers and footers.

    If you click the link I posted previously, it takes you right to the Pages community.
    Here >  Pages: iWork: Apple Support Communities
    Then click New.

  • How do I print only the first page of multiple PDF documents?

    I have about 1,500 PDF files (scientific papers) that I need to print only the first page of... Any suggestions on how to do this as a single job or as a few jobs? The files are organized in a bunch of different folders, so if there was some way to do this folder by folder, that would be ok too. Thanks!

    Make sure that in System Preferences Printing & Fax pane you set the default printer to the one you want to use, then put all of these PDF files into their own folder, then open terminal and type the following (without hitting return afterward):
    lpr -o page-ranges="1-1"
    Then drag one of the PDF files into the terminal window (it will add it's path to the end of your command) and replace the file name with *.pdf, so it will look like this:
    lpr -o page-ranges="1-1" /Users/todd/Documents/My\ Folder/*.pdf
    Then hit return.

  • Is there a way to automatically go to the first page of an articles when navigating through a folio

    If the user scrolls to the final page of Article A and then swipes to the right to Article B, is it possible that when they swipe back to Article A it will default to the first page as opposed to the last page?

    You would need to use a button or link and a navto path. Digital Publishing Suite Help | Hyperlink and button overlays

  • Return the User to the Calling Page - doesn't work

    Hello All,
    I set up the "Issue tracker" tutorial to get in tuch with the apex (htmldb vers. 2.0)
    All is working well but: Return the User to the Calling Page -> doesn't work. I performed all steps as descriped in the tutorial (iclusive the '.' on the &P7_PREV_PAGE ;-) ).
    I use my own aplication at home and followed all the instruction steps few times but it does not work. Can you help me please?
    Do I have to install something more?
    In the Branch section: * 1: Go To Page &P7_PREV_PAGE. (Unconditional)
    In the Item section: 90: P7_PREV_PAGE Hidden
    In the Button section for cancel Button: &P7_PREV_PAGE.
    Here is the description of the function in the tutorial:
    Because this Create/Edit page will be called from several places, when users finish with the display they should return to the calling page. To accomplish this, you create an item and change the branch on this page. Every time this page is called, the item must be set with the number of the calling page.
    To create a hidden item:
    1. Under Items, click the Create icon.
    2. For Select Item Type, select Hidden and click Next.
    3. For Display Position and Name:
    1. For Item Name, enter:
    P7_PREV_PAGE
    2. For Region, select Issue Identification.
    3. Click Next.
    4.
    Click Create Item.
    Next, edit the Cancel button.
    5. Under Buttons, select Cancel.
    6. Scroll down to Optional URL Redirect.
    7. In Page, enter:
    &P7_PREV_PAGE.
    Note the period at the end.
    8. Click Apply Changes.
    Next, edit the branch.
    9. Under Action, enter the following in Page:
    &P7_PREV_PAGE.
    10. Click Apply Changes.
    All steps are done but I still got the message: Error ERR-1016 Application "106" Page "0" not found (requested language="de")
    OK
    I move the mousepointer over the cancel button: javascript:redirect('f?p=106:0:5265993428922076876::NO:::')
    Thank you for helping me!
    best regards Thorsten

    All,
    I haven't looked at that tutorial for quite a while but just gave it a quick look.
    Further down in the tutorial, it directs you to set the value of P7_PREV_PAGE, under Add Functionality to Support Adding Multiple Issues Sequentially - have you done that? There is also a mention that there is more branching to be done - "The branch you just created is looking for a value in P7_PREV_PAGE. Since the page was not called from another page, the value has not been set. You need to fix that next." It goes on to have you define that value from other places.
    Can you describe what you are doing when you get the error? There could be something missing from the tutorial. A way around it would be to create a default value for P7_PREV_PAGE so that if it is not set, a default page will be used.
    -- Sharon

  • Macbook Pro won't print the first page of any file in any application.

    Problem: My Mid-2009 Macbook Pro won’t print the first page in Microsoft Word, Sibelius 6, or in Adobe Reader. My printer is an old Canon MP480 that’s worked for almost 2 years perfectly. As well, the “print to pdf” function results in the same error. However, if I open a new user account it all works fine. To change user accounts would be an extreme hassle though so, if possible, I would like to first remedy this one.
    Recent changes: the motherboard of my computer was replaced about a week and a half ago. I printed a lot of stuff from Word two days ago and that worked fine but, already then the print to pdf function was cropping off the first page. At the time, though, I accredited the issue to the word documents being filled with pictures of sheet music that I was printing instead of text.
    Things I have tried:
    Updated Mac software
    Repaired Disc Permissions in Disk Utility
    Checked for new printer drivers/firmware
    Reset the PRAM (http://support.apple.com/kb/ht1379.)

    No but it's not a printer-related issue because the "Print to PDF" function also leaves out the first page.

  • ESS Portal Trip/Expense form only prints the first page

    Good morning;
        Our users reported that when they display a trip/expense via Portal and then right mouse click in order to print the trip, only the first page prints out.  If they go to the SAP Gui and run the TRIP transaction and display the trip in Print Preview form and print it, they get all the pages of the trip/expense printed.
    Has anyone ever run into this strange issue before?
    Thanks.
    Scott.

    Thanks for the quick response.
    I'm assuming that you are refering to the IMG Path:
    Cross-Application Components->Homepage Framework->Resources
    ->Define Resources
    Select activity Define Resources (Change Entries)
    When I check this in the IMG, we do not have a resource called  EMPLOYEE_TRAVEL_TRIPFORM_SRV05.
    Currently we are on ECC 5.0 and note 525862 references Rel 4.6c so I know that those corrections are part of our system.  The 812903 note refers to ECC 6.0 only so this note I believe would not help us.
    Should I add the resource EMPLOYEE_TRAVEL_TRIPFORM_SRV05 to the Configuration?
    I see that note 1140369 references something about the EMPLOYEE_TRAVEL_TRIPFORM_SRV05 resource and has something to do with hight of the Trip form.
    Scott.

  • When I open a template I only get the first page. Any ideas?

    Hi, When I open a template in Pages I only get the first page and not the continuation pages. Does anyone have any ideas of what I'm doing wrong? Thanks.

    This same question was asked & answered earlier today. I'll use my same response & the same screenshot I used then.
    Skimming the templates in the Template Chooser shows you all of the pages available in the template once you open it. You can insert the one(s) you want, even more than one of any of them. Most users don't want or need all of the different pages, especially when they start the document.

  • Why does Safari only display the first page of PDFs

    When I use Safari to view PDFs attached to a web site I manage only the first page of the PDF displays. There is no problem if I use other browsers. Also the problem is specific to my machine as other Mac users can view all pages of the PDF on their machines. I have looked at Safari Preferences but there does not appear to be any incorrect settings.

    Hi
    do you have any 'pdf' plugins showing in HD/Library/Internet Plug-Ins/ ?
    If you do, quit all browsers & drag the plugin to the Desktop, or some other folder, then test pdf's again. If they still display oddly, try quitting Safari & removing the file Home/Library/Preferences/com.apple.Safari.plist.
    If np pdf plugins show, try the plist move anyway & if you still have problems, it's helpful to test this in a New User Account which takes but a few minutes & tells us if it's a system-wide issue, or restricted to your regular user.

  • When printing multiple pages from an internet email or webpage, only the first page is properly fitted on the page. All subsequent pages are cut off on the right side. What's the fix?

    I have set the print settings to "Ignore scaling and Fit to Page" and it seems to work only for the first page of a multi-page webpage or email chain. Nothing I've done seems to fix it. I've set the print settings to 90% scale in page set-up in order to print FedEx online waybills properly, but I can't seem to solve the other problems.

    Doc: I've had a similar experience, and here are the details, investigation, and a workaround. My printer is a Brother MFC-645CN, and I'm using Snow Leopard (10.6.8) on a 2010 iMac quad i5 connected to the printer over my ethernet LAN. Are you using a Brother printer?
    Firefox has shown this kind of nasty issue for the past six months or so. It seems to be related to the imaging algorithms in Preview when dealing with Firefox (now at v.12) and the Brother printer -- the screwy second page (and beyond) show up skewed and up-sized when doing a print preview also. No such problem seen in Safari or anything else. I am not currently using any other Mozilla apps on this Mac besides Firefox.
    A few months ago I tested printing from my administrator account and  a different user account. Firefox printing was completely normal and as expected. When I went back to my main user account, back came the funky second page.I went through extensive troubleshooting to try to chase it down, systematically removing and replacing apps and preferences and many other Library files related to printing, Brother drivers, Firefox, and Preview. Nothing helped. Solution was to migrate my user files to an account where the printing problem wasn't happening. I deleted the problem user account.
    Everything was fine for about three weeks, and then with no warning, printing was back to the bad second page, just as before. I am stumped, and I'll let smarter people try to figure it out. I use Firefox a lot, and it's possible that some add-on setting is interfering, or a web page I visited turned the printing funky again. I just don't know.
    Also checked on a Mac G4 running Leopard (10.5.8) and Firefox 3.6.28. No printing/preview problems there.
    Now, for the work-around I am currently using -- print each page separately, one at a time. Page 1, then page 2, etc. Preview and printing looks completely normal. Hope this works for you until the bug is located and squashed for good.
    Glenn

Maybe you are looking for

  • P key issues on Macbook pro

    Hello! A few nights ago my girlfriend's lowercase p key stopped working properly. When pressed it activates the volume down function on F11. The uppercase P works however, but she recently told me that pressing capslock makes a comma. It is a 15 inch

  • Problem including a jsp in edit mode

    Hello Somehow i have a problem while including a jsp page while displaying the edit mode. If my doEdot just writes something like "Hello World" into the response it just works fine. But if i try to include a jsp resource the problems start to arise:

  • QT Playlist Manager

    Hi all, This one is killing me cause it seems simple. Im trying to have QT or any other player for that matter play a playlist on schedule time. An example would be 1. Drag & drop video file(s) into playlist 2. Playlist plays the full list then repea

  • Device switch Problem from 9360 to Z10. Help Please

    Hello; I just switched from 9360 to Z10. But when I log in with my last account. Only 12 contacts re coming and some of them re not even in my contacts. Please someone can help me?  Thanks in Advance. Ozkan

  • TS3899 iPhone 5s Mail app shut down automatically when try to send email

    I just set up new iPhone 5s two days ago from iPhone 5. Everything works fine except Mail app. Due to Mail app, I had to set up new configuation instead of back up from old iPhone 5. Mail app works fine 1 day, but after the day after, the mail app sh