User Name
Password
AppleNova Forums » Programmer's Nook »

Dynamic Assignation vs. Stable URL


Register Members List Calendar Search FAQ Posting Guidelines
Dynamic Assignation vs. Stable URL
Thread Tools
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2005-12-10, 10:45

In the 'People' section of my Film-GA.com website I have made a little roll-through gallery of individual bios of people who work in the film industry in Georgia. The gallery works fine. The problem is that I'm lazy. I just made a tab-separated "control" text file for all of the entries and load that into an array. Easy peasy.

It goes:
filename [tab] person's name [tab] department/job [tab] description [cr]

This is great and easy and simple and all, but I've complicated matters by deciding to insert new entries alphabetically. As soon as I do that the numerical assignment for the entries that follow the new entry change.

Bottomline: Ralph sends the URL of his entry to his mom, she checks the next day (after I've added Jenny) and all of a sudden she's seeing Paul's entry instead of her son's.

I have to drive to a wedding today but thought that I'd jam this out here to see if anyone had recommendations as to the best way to fix this. I know that I'll have to write some code that alphabetizes the list for me, which will free me up from having to manage the control file myself.

And in case you suggest mySQL you should know that I'm mySQL illiterate. This list of bios isn't going to be enormous anyway... it's like pulling teeth to get people to give you their info.

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2005-12-10, 11:15

MySQL would work best but your way will work fine...just stop using numbers. What is the need to do this? I might not be getting something.

Quote:
Originally Posted by drewprops
I know that I'll have to write some code that alphabetizes the list for me, which will free me up from having to manage the control file myself.
It seems like that is all you have to do if I understand correctly...and that is really easy to do. So your set
  quote
Mr Beardsley
Member
 
Join Date: Jul 2004
Location: Colorado Springs
Send a message via AIM to Mr Beardsley  
2005-12-10, 11:41

This doesn't help you with your current problem, but just for the future:

Don't fear the MySQL, databases are your friend! SQL is a really easy syntax to wrap your brain around, and I guarantee you can pick it up in 20 minutes. If its intalling MySQL, there is a prebuilt MySQL installer for OS X on the MySQL website. Last but not least there is a GUI that works pretty good for seeing your databases. Its called Cocoa MySQL. You can get the whole thing running without hitting the terminal at all.

If you want to give it a whirl, I'm sure the folks here can help you with any issues you have.

"Slow vehicle speeds with frequent stops would signal traffic congestion, for instance."

uh... it could also signal that my Mom is at the wheel...
  quote
pmazer
Member
 
Join Date: May 2005
Location: Atlanta, GA
Send a message via AIM to pmazer  
2005-12-10, 14:05

I think the easiest way to fix this is going to be to reference the people by their name, rather than an arbitrary number. Instead of: http://www.film-ga.com/?sec=people&p=1 use http://www.film-ga.com/?sec=people&p=Linda%20Burns. In order to get the previous and next URLs, just simply find the previous and next person in alphabetical order. This may be a bit more costly in terms of CPU time, but as long as you don't have a million people you should be fine.
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2005-12-11, 00:56

The host for this site has a cherry installation of mySQL - I'm already using it to teach myself WordPress on the side so I'll take a look at some mySQL projects in a book I have and see if I'm motivated to learn it right now. Otherwise I'm going to give pmazer's suggestion a look-see as well as looking to see how easy it is to sort an array alphabetically... it can't be all that difficult, relatively speaking.

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2005-12-11, 07:26

Check it.

Give you a little idea. It's not very hard at all, you'll see. Also, don't be afraid to check out MySQL's site, that is how I learned, and I think they did a pretty good job in their tutorials.
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2005-12-11, 09:46

Oh wow, asort is awesome!!
I just tried it out and it's not the right solution this time around because I've just jammed people's full names into an array (no first/last setup).... the resultant sort is by the first letter of the first name.

I've used pmazer's suggestion of simply passing the person's name instead of their slide number, which works great until it runs into an Irishman. Does PHP not like the Irish for some reason?

http://film-ga.com/?sec=people&p=Timmy%20O'Brien

I'm guessing that it's that apostrophe that it doesn't like? What to do, what to do...

I'll be learning mySQL here soon. I've come to believe that organizing your data properly is more important than learning the tools to manipulate that data.

EDIT: Crap. The single apostrophe wants to be escaped. Tracking down the &whatever; code for the single apostrophe now....

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter

Last edited by drewprops : 2005-12-11 at 10:19.
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2005-12-11, 11:24

I believe it's & #8217; (no space between the & and the #)

While I agree MySQL is the best way, you could just change how you load your information into the array. PHP has pretty great string manipulation functions, it would be easy to load their name separately into an array.
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2005-12-11, 17:54

I had a long-ass post about how I was testing for this case and that case. I had PHP code included, it was very neat. I did some output of various variables and found that PHP was automagically inserting a backslash in front of the apostrophe in the value passed by 'p'.

Then I remembered stripslashes() --- life is good.

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-12-11, 18:25

Quote:
Originally Posted by drewprops
EDIT: Crap. The single apostrophe wants to be escaped. Tracking down the &whatever; code for the single apostrophe now....
Don't make a special case about it!

For all your URL character-escaping needs: string urlencode ( string str )

  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools

« Previous Thread | Next Thread »

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


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova