Start New Discussion Reply to this Discussion Linking a random number from a mysql query
Hello,
I am a newb all the way around and I hope that I explain this thoroughly in order to get the help I need. I have a mysql db inside of my python program that generates a hint. I need to have a random number (which will later be transferred to a barcode/image) that prints to the next hint but links back to the previous hint. For example, the program hints, "This thing grows apples." You go to an apple tree and there is a barcode you scan to get the next hint. Each hint is unique but grouped by a location. What is the best way to link the number between the two hints?
Related Article: python random number
is a solved Python discussion thread by efwon that has 6 replies and was last updated 5 months ago.
LinaClark
Newbie Poster
5 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
I'm not sure I follow. If it's a random number, then it won't point reliably in either direction, no? Is this maybe what you want?
There is a list of hints, lstHints. For each element of lstHints, there is a tuple, (n1,n2), where lstHints[n1] is that element and lstHints[n2] is the element you go to next. While it might seem that this is a dictionary, I don't think it is, as I am envisioning lstHints as being ordered and dictionaries are not. Basically it's two linked lists, one being lstHints and the other, say lstTuples.
rrashkin
Light Poster
47 posts since Nov 2012
Reputation Points: 13
Solved Threads: 15
Skill Endorsements: 2
I think this will work, I am going to try this. Thank you so much. Oh, btw, with it like this, the numbers dont have to be random. However, could I make a tuple of images, or would I have to make a table (in the db) and join both tables together?
LinaClark
Newbie Poster
5 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
I'm afraid I don't follow. What are you trying to accomplish?
rrashkin
Light Poster
47 posts since Nov 2012
Reputation Points: 13
Solved Threads: 15
Skill Endorsements: 2
© 2013 DaniWeb® LLC
Page rendered in 0.0634 seconds
using 2.65MB