eristic Posted May 11, 2008 Share Posted May 11, 2008 I would like to create: A simple form that, when entered, your answer would be added to a list of many others (perhaps in a table). For example, I would enter: "Animal Collective - The Feels" and it would add to a list of many other music suggestions upon submitting. I know how to do this, but the bigger goal that I do not know how to do is this: I would like the answers randomized with each browser refresh. My reasoning for this is to eliminate the need for people to post "First! Woot woot! Yesssssssssssss..." then get on with their actual help. One's answer is not the most important. It is the collection of music suggestions that is. Ideally, I would like to not use a forum, but have a simple form followed by a table of text once submitted so that you can view the other randomized answers. Hopefully, their suggestion would be lost in the mix already so they can view other's music suggestions. Thanks so much for the help. eristic Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/ Share on other sites More sharing options...
peranha Posted May 11, 2008 Share Posted May 11, 2008 Do you mean something like this? // create query $query = "SELECT * FROM table ORDER BY rand() LIMIT 1"; that would be for a sql database. It would select 1 random post. Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538076 Share on other sites More sharing options...
mlin Posted May 11, 2008 Share Posted May 11, 2008 Ok, so you've got a table full of music suggestions and you'd like to randomize the suggestions shown on each refresh. You can use the rand() cmd in your sql query...such as: select suggestions from music order by rand() limit 10 if your just randomizing the Entire list of suggestions, get rid of the limit in your query Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538077 Share on other sites More sharing options...
mlin Posted May 11, 2008 Share Posted May 11, 2008 lol beat me to it =) Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538078 Share on other sites More sharing options...
eristic Posted May 11, 2008 Author Share Posted May 11, 2008 Excuse my ignorance, but I have no idea if that is what I want. While I know how to make and view .php files, the computer I am on will not let me save them correctly (silly girlfriend computer!). I assume it is since both of you submitted the same php but I have no way of viewing it right now. Thank you for your quick help. eristic Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538080 Share on other sites More sharing options...
eristic Posted May 11, 2008 Author Share Posted May 11, 2008 Ah, I see now. No, I would prefer that you can view all suggestions (scroll down) not just one. But, that all results are randomized. Perhaps limit the result to five? Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538082 Share on other sites More sharing options...
peranha Posted May 11, 2008 Share Posted May 11, 2008 just change the number after LIMIT to what ever number you want to limit the posts returned to, and if you dont want to limit the number of posts, get rid of the LIMIT at the end, just end at rand() Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538085 Share on other sites More sharing options...
eristic Posted May 11, 2008 Author Share Posted May 11, 2008 // create query $query = "SELECT * FROM table ORDER BY rand() LIMIT 5"; I suppose? And what is the best script for a blank text field and submit button? The simpler is better for me. Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538086 Share on other sites More sharing options...
mlin Posted May 11, 2008 Share Posted May 11, 2008 huh? html for blank input field and submit? <form action='' method='post'> <input type='text' name='blank' /> <input type='submit' value='Post' /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538102 Share on other sites More sharing options...
eristic Posted May 11, 2008 Author Share Posted May 11, 2008 Thanks for all your help! Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538111 Share on other sites More sharing options...
retro Posted May 11, 2008 Share Posted May 11, 2008 You might want to use two text boxes - one for artist, the other for song. So often you find people don't standardize what they write, and with a more obscure artist, it is difficult to tell which is the artist and which is the song! For example, you might get something like: Stomp - Elephant. Is the artist Stomp or Elephant? Of course, if you did this, you would have two fields in your database, and call the two together, e.g.: echo $row["artist"] . " " . $row["title"]; Quote Link to comment https://forums.phpfreaks.com/topic/105105-randomized-form-answers/#findComment-538209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.