Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: My First All PHP Script

  1. #1
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default My First All PHP Script

    Hi Everyone,

    As you may or may not know, I'm a relative beginner at PHP but my extensive knowledge of javascript has helped me some.

    Up until now though I've used what PHP knowledge I have to occasionally suggest fixes for others and/or for incorporation with javascript.

    An opportunity presented itself to make an all PHP quotes script, so I did:

    Quote Demo

    I'm interested in what folks might have to say about it.

    Any comments?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #2
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default

    Interesting script.

    I like the options you have-prev,random,next and also #-number

    I also like the way you have a short description as well as the full one.

    If it were me I would switch the two and have the brief description first then the full one second but that is my personal preference-lol
    Thanks,

    Bud

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Um the short description is a history. After you've made a second choice, the long description changes to it, while the short description is added to the top of the history. And so on unless you clear the history with the Clear link or by ending the browser session. You can keep adding to the history, keeping your favorites near the top by clicking on their number in the history list. This will promote them to the top again.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    I don't know much about PHP, but what strikes me is that http://jscheuer1.comli.com/quotes/quote_w.php is the static part of all your pages (before the question mark (query)). What changes is the part after '?'. Is this comparable to what I do with javascript here? Click on 'Pages of site' (top left) and choose an internal page. My HTML address bar is very much simiar to your PHP address bar. My http://mesdomaines.nu/lesserknowncla...ic/index1.html seems to be your http://jscheuer1.comli.com/quotes/quote_w.php. So does a page change in your case mean that a new file is added to a static file (http://jscheuer1.comli.com/quotes/quote_w.php, in your case) in the same way a page is added to a static file (http://mesdomaines.nu/lesserknowncla...ic/index1.html) in my case?
    Just curious.
    Arie.
    ===
    Last edited by molendijk; 08-09-2012 at 12:00 AM. Reason: Correction in text

  5. #5
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    1 quick thing -

    http://jscheuer1.comli.com/quotes/quote_w.php?hqnum=326

    It just minuses the total (324) on then goes to that page... (In this case #2). I don't particularly like that... I'd have a "Quote not found" error instead....

    Also, is there any reason there isn't a submit button next to the "Go To" feature?

    When I go to a random quote, than navigate away from that quote (to a different quote) then back to that quote either qith the previous/next or the #box... It doesn't update the quote from being a "random quote" (the * doesn't go away). Something to think about...

    I assume you're just using the GET variable to pick a quote from the database and storing the history in a session? Would I be correct?

    I like the random quote feature!!!
    Nice little script!

    Random little thing; Down the bottom - Permission - shouldn't that be a lowercase?

    P.s. Love #54
    Last edited by keyboard; 08-09-2012 at 12:17 AM. Reason: Added in some stuff

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    nice - clean, functional. gonna share the source?

  7. #7
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Can I put my vote in for the source as well?

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by keyboard1333 View Post
    It just minuses the total (324) on then goes to that page... (In this case #2). I don't particularly like that... I'd have a "Quote not found" error instead....
    I thought about that. It could be an option in the script. As it is, it would be easy to add. I decided to go with subtraction (Modulus actually) though, so as to make the experience less jarring.

    Quote Originally Posted by keyboard1333 View Post
    Also, is there any reason there isn't a submit button next to the "Go To" feature?
    A form like this one with only one text input may be submitted by hitting enter. A submit button could be added.

    Quote Originally Posted by keyboard1333 View Post
    When I go to a random quote, than navigate away from that quote (to a different quote) then back to that quote either qith the previous/next or the #box... It doesn't update the quote from being a "random quote" (the * doesn't go away). Something to think about...
    It says right on the page:

    *a quote chosen at random at some point
    I also thought of what you're saying though. I'm sure it could be done. But I also thought it would be nice to have a record of which ones were chosen at random even after they were either recalled intentionally or hit upon during prev/next navigation.

    Quote Originally Posted by keyboard1333 View Post
    Random little thing; Down the bottom - Permission - shouldn't that be a lowercase?
    I thought that too, and have corrected it for the archive I'm attaching. I'll get it on the live version soon.

    For those wanting the code, here it is:

    Attachment 4578
    Last edited by jscheuer1; 08-09-2012 at 03:49 AM. Reason: detail
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Quote Originally Posted by jscheuer1 View Post
    A form like this one with only one text input may be submitted by hitting enter. A submit button could be added.
    I knew it could be submited with the enter bar (I was using it), I just though having a submit button would be nice if you wanted to click it...

    One other thing; Have you thought about storing the history in a cookie instead of a session (so it shows up if they close->re-open the browser).

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I had thought about it. But this is such unimportant data . . . In any case it would be easy enough to change.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •