I am looking for some direction and advice. I am working on a personal project to build my PHP skills, and what I am trying to do is simply create a form that pulls its data from a mySQL table, the user then inputs info and submits it to the database, simple enough, sure, but I would like to do it with loops.
I have a PHP document that builds a table called "critique_instructor" submits some questions to a database called "critique"
I have a separate PHP document that pulls those questions from the database using a loop. I also have a dropdown box to select a value.
I am looking for direction on how to go about inputing the values the user selects from the drop down that is associated with each question into my database.
I am also looking for advice if you guys think this is the correct way to go about doing it?
here is my PHP code:
Code: Select all
<?php
//Make a MySQL Connection
mysql_connect("localhost", "root") or die(mysql_error());
mysql_select_db("critique") or die(mysql_error());
// Get all the data from the "critique_instructor" table
$result = mysql_query("SELECT * FROM critique_instructor") or die(mysql_error());
?>
<html>
<head>
<title>
Student Critique
</title>
</head>
<body>
<?php echo '<h1>STUDENT CRITIQUE</h1>'; ?>
<br>
<?php echo 'In order to provide thorough training, we need your honest opinion about the training you are receiving. It
is not necessary to sign your name and in no way will your answers here reflect in your final grade. Your
frank and honest answers below will help us improve.'?>
<p><?php echo '<u>Part 1 – Your instructor</u>'?>
<p><?php echo 'Please rate each statement from 1 to 5, based on the following scale.'?>
<p><?php echo "5………Excellent 4………Good 3………Average 2………Below Average 1………Poor"?>
<form action="process.php" method="post">
<!--keeps getting the next row until there are no more to get-->
<?php while($row = mysql_fetch_array( $result )) {?>
<?php echo $row['id']." - ".$row['critique_question'];?>
<select name="rating">
<option>5 Excellent</option>
<option>4 Good</option>
<option>3 Average</option>
<option>2 Below Average</option>
<option>1 Poor</option>
</select>
<br>
<?php } ?>
Use this space for any additional comments or special questions:<br>
<textarea name="additinal_comments" rows="5" wrap="physical">
Enter Comments Here
</textarea>
<p><input type="submit">
</form>
</body>
</html>