Jump to content

jhl84

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jhl84's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. what do u guys think of this? extract ($_POST); $query = ("SELECT * FROM email WHERE email = $email"); $result = mysql_query($query); if (mysql_num_rows($result) == 14) { // Already answered all questions } else { // generate random no until found question do { $id = rand(1, 14); $query = ("SELECT * FROM email WHERE email = $email AND qid = $id"); $result = mysql_query($query); } while (mysql_num_rows($result) <= 0); $id = rand(1, 14); $query = ("INSERT INTO email VALUES ('$id', '$email')"); $result = mysql_query($query); $resQ = mysql_fetch_array(mysql_query("SELECT * FROM question WHERE qid = $id")); $resA = mysql_fetch_array(mysql_query("SELECT * FROM answer WHERE aid = $id")); echo $resQ['quest']."<br/>"; }
  2. yea i need help finishing the code.... u see, i need that query the database for the email whether it exists, if it does, then checks the 'no' field in the email table. if the 'no' is same with the random $id generated, then it will regenerates another $id until it is different. if (($query['email'] == $email) && ($query['no'] == $id)) { //the problem is here } i wan it to continue regenerating $id until it is different. the email table in db consists of 'no' and 'email'.
  3. Hi...I am building a page that displays random questions to visitors. At the first page, the user will enter his email n be directed to another page where a random question from the database will b given. if the same email address is entered, the question that was given will not be repeated n other question will b given instead. all the questions n answers r stored in the database with a unique id. so far this is what i hv done. extract ($_POST); $id = rand(1, 14); $query = ("SELECT * FROM email WHERE email = $email"); if (($query['email'] == $email) && ($query['no'] == $id)) { } else { $query = ("INSERT INTO email VALUES ('$id', '$email')"); $result = mysql_query($query); $resQ = mysql_fetch_array(mysql_query("SELECT * FROM question WHERE qid = $id")); $resA = mysql_fetch_array(mysql_query("SELECT * FROM answer WHERE aid = $id")); echo $resQ['quest']."<br/>"; } i hope i'm not confusing u guys. do advice
  4. just curious, say i want to enter a really long text into mysql such as this Then you’ll surely be able to spot the missing 3rd line for this stanza from Material Girl – Madonna: Some boys romance, some boys slow dance That’s all right with me … Have to let them be i think it is not possible to enter it in that form right? u need to format it using php after extracting it?
  5. i'm sorry but i dont understand wat the caption is? thanks for ur help. btw, i would like to know wat u think of the sql i wrote? do u think it will work as nicely as urs?
  6. hey grego, thanks for the idea! it sounds great! what do u think of this? SELECT q.quest, answ FROM questions q, answers a WHERE q.id = a.id ORDER BY rand() LIMIT 1; from this sql, i hope it can select only one set of question n answer randomly. is it correct? *modified code
  7. i hv a set of questions n each questions has a different choice of 4 answers. how do i group the question n answers together?
  8. Hi, I would like to generate ONE question for a user whenever he visits my page. The questions r stored in the database. And the user will hv to enter his email which is stored in the database. If the email is entered the second time, a different question will be given. so my question is, how do i make sure that the same question will not b repeated if the same email is entered? any suggestions? do advice pls...thanks!
  9. Hi guys, i have this number, 878777886XXXXXX. The Xs represent random numbers that I want to generate. I want to generate 1000 numbers that does not repeat using php. can anyone help? thanks!
  10. i have written codes for an email form. but the email form doesnt work. i think the problem is from this line. [code]mail('jhl84@domain.com',$subject,$text,"From: $name <$email>");[/code] from this line, i am using the mail() function. do i need to get a smtp server, configure the php.ini file or use the pear mail found in the php folder? i am using apache and installed php triad running on windows xp pro. pls help. thanks...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.