| | |
trying to make a survey for school yearbook, need help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Dec 2007
Posts: 63
Reputation:
Solved Threads: 0
Hey guys, i just registered here. I have always read posts here but never thought to register.
Anyways, i am looking for some help with this script. So i have about 300 students that all need to be placed in option statements (html). I need these names then put into a drop down menu for students to choose. The issue is, i have maybe 30 questions, which means that i have a hell of a long script. Is there anyway using mysql to import these names whenever i need them into a drop down menu? Also i plan to get the script to submit to a mysql database, what is the easiest way to do that and will allow me to extract the choices the easiest?
And last thing i need to know how from those names i submit into the database to use them also in my verification script. I would liek to generate random passwords for all the users then have them printed out and handed out to the students for them to login. How can i get that done? Also how do i hook it up to a login page?
Thanks so much, Dani.
Anyways, i am looking for some help with this script. So i have about 300 students that all need to be placed in option statements (html). I need these names then put into a drop down menu for students to choose. The issue is, i have maybe 30 questions, which means that i have a hell of a long script. Is there anyway using mysql to import these names whenever i need them into a drop down menu? Also i plan to get the script to submit to a mysql database, what is the easiest way to do that and will allow me to extract the choices the easiest?
And last thing i need to know how from those names i submit into the database to use them also in my verification script. I would liek to generate random passwords for all the users then have them printed out and handed out to the students for them to login. How can i get that done? Also how do i hook it up to a login page?
Thanks so much, Dani.
Last edited by dani190; Dec 29th, 2007 at 7:34 pm.
•
•
•
•
So i have about 300 students that all need to be placed in option statements (html). I need these names then put into a drop down menu for students to choose.
php Syntax (Toggle Plain Text)
<?php $conn=mysql_connect($host,$username,$pass); mysql_select_db($dbname); $query="select student_name from student"; $result=mysql_query($query); echo "<select name=\"student_name\">"; while($row=mysql_fetch_array($result)){ echo "<option value=".$row['student_name'].">".$row['student_name']."</option>"; } ....
This will put all the student names in the select box.
•
•
•
•
The issue is, i have maybe 30 questions, which means that i have a hell of a long script. Is there anyway using mysql to import these names whenever i need them into a drop down menu?
•
•
•
•
Also i plan to get the script to submit to a mysql database, what is the easiest way to do that and will allow me to extract the choices the easiest?
•
•
•
•
And last thing i need to know how from those names i submit into the database to use them also in my verification script. I would liek to generate random passwords for all the users then have them printed out and handed out to the students for them to login. How can i get that done? Also how do i hook it up to a login page?
Cheers,
Nav
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Jan 2008
Posts: 79
Reputation:
Solved Threads: 9
hi dan maybe u can check php.net theres a good resources to learn it, and u can download php manual there ....
•
•
Join Date: Dec 2007
Posts: 63
Reputation:
Solved Threads: 0
•
•
•
•
If you have these 300 students info in a table, then just fetch their info by using loops. Say, for example, you have student table with their info. You get the dropdown by doing something like this.
php Syntax (Toggle Plain Text)
<?php $conn=mysql_connect($host,$username,$pass); mysql_select_db($dbname); $query="select student_name from student"; $result=mysql_query($query); echo "<select name=\"student_name\">"; while($row=mysql_fetch_array($result)){ echo "<option value=".$row['student_name'].">".$row['student_name']."</option>"; } ....
This will put all the student names in the select box.
30 questions ? What 30 questions ? About your second question, yes, you can write a function and whenever you need values from the table, you can call that function.
If you want to submit the user's input to a table, you do it using an insert statement. When the user submits the page, the form variables are accessed as $_POST['variable_name'] or $_GET['variable_name'] depending upon the method you want.
You will find a lot of scripts on the net to generate random password. If you want a simplest random password generator, have an array of alphanumerics. (a-z A-Z 0-9). Generate a random number and fetch that array element.
Cheers,
Nav
also how do i now generate random passwords for everyone? I made a field called password in the mysql just i don't know how to generate the random password
Replace student_name with user_id in the query that I have given above. Then change, $row['student_name'] to $row['user_id'].
As I said earlier, generating random password is easy. Check this site. Use that function in your script.
As I said earlier, generating random password is easy. Check this site. Use that function in your script.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 63
Reputation:
Solved Threads: 0
PHP Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Etobicoke Collegiate Institute's Grad Survey 2008</title> </head> <body> <form action="handle.php" method="post"> <fieldset><legend>Please complete the following questions. Thanks!</legend> <label>1. Be on the price is right</label><br /> <select name="priceisright"> <option value="">Please Choose One Person</option> <option value="">Not Voting</option> <?php $conn=mysql_connect($host,$username,$pass); mysql_select_db($dbname); $query="select user_id from student"; $result=mysql_query($query); echo "<select name=\"student_name\">"; while($row=mysql_fetch_array($result)){ echo "<option value=".$row['user_id'].">".$row['student_name']."</option>"; } ?> </select> <br /> </body> </html>
But it doesnt seem to work. Sorry i am bugging you so much but i am quite new to php
![]() |
Other Threads in the PHP Forum
- Previous Thread: Formatting blob fields
- Next Thread: Basic Web App
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code codingproblem cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory menu methods mlm mod_rewrite multiple mysql oop parameter parse paypal pdf php problem query radio random recursion regex remote script search select send server sessions sms soap source space speed sql static structure syntax system table tutorial up-to-date update upload url validation validator variable video web wordpress xml youtube






