View Full Version : My First All PHP Script
jscheuer1
08-08-2012, 02:40 PM
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 (http://jscheuer1.comli.com/quotes/quote_w.php)
I'm interested in what folks might have to say about it.
Any comments?
ajfmrf
08-08-2012, 06:21 PM
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
jscheuer1
08-08-2012, 06:28 PM
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.
molendijk
08-08-2012, 11:43 PM
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 (http://mesdomaines.nu/lesserknownclassicalmusic)? 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/lesserknownclassicalmusic/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/lesserknownclassicalmusic/index1.html) in my case?
Just curious.
Arie.
===
keyboard
08-09-2012, 12:10 AM
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
nice - clean, functional. gonna share the source?
keyboard
08-09-2012, 01:42 AM
Can I put my vote in for the source as well? :D
jscheuer1
08-09-2012, 03:03 AM
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.
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.
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.
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:
4578
keyboard
08-09-2012, 04:18 AM
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).
jscheuer1
08-09-2012, 04:36 AM
I had thought about it. But this is such unimportant data . . . In any case it would be easy enough to change.
cool.
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).
I'm a little surprised you (John) didn't do it that way. I'd use localStorage (there are several JS polyfills for browsers that don't support web storage yet). But I understand, we're focusing on the PHP side.
code is good. biggest thing I'd change is how you're storing the quotes -
array( quote,citation,quote,citation ) is pretty fragile. For a flat file, I'd use JSON, and put each quote/citation pair in their own array.
[
[ quote,citation ]
,[ quote,citation ]
]
if you'd like to hear more, let me know. I'll read it all the way through tomorrow.
jscheuer1
08-09-2012, 05:13 AM
I'd thought of that too. And it is a better way to do it. But the way they're stored now is so much easier to maintain, especially for a non-coder. It would be fairly easy to change things around to accommodate various formats for the quotation file/data.
Sure, I did this to learn as much as anything else. And that's one of the reasons why I posted, to get comments.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.