tahj Posted November 20, 2007 Share Posted November 20, 2007 The radio buttons for each question should consist of the following options: No Opinion, Poor, Fair, Good, or Excellent. Separate text files should store the results of a single survey. Include a View Past Survey Results button on the main survey page that displays a list of past survey results. We already have the radio buttons part. I am not sure how to make a MySQL file that will create a separate text file for each entry. Here is the php file we currently have: <!DOCTYPE html PUBLIC "-w3c/DTD xhtml 1.0 Transitional//EN" "http://w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Airline Survey</title></head> <body> <?php $Flight_In = $_POST["Flight"]; $Date_In = $_POST["Date"]; $Time_In = $_POST["Time"]; $Friendliness_In = $_POST["FriendlinessRad"]; $Space_In = $_POST["SpaceRad"]; $Comfort_In = $_POST["ComfortRad"]; $Cleanliness_In = $_POST["CleanlinessRad"]; $Noise_In = $_POST["NoiseRad"]; echo "$Date_In"; $File = "Survey.txt"; file_put_contents ($File, $Flight_In); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/78024-need-help-with-doing-this-part-of-the-file/ Share on other sites More sharing options...
PHP_PhREEEk Posted November 20, 2007 Share Posted November 20, 2007 No Opinion = 0 Poor = 1 Fair = 2 Good = 3 Excellent = 4 Store as integers in MySQL. You can then build averages or whatever. Integers are easy to work with, easy to store and easy to retrieve. PhREEEk Link to comment https://forums.phpfreaks.com/topic/78024-need-help-with-doing-this-part-of-the-file/#findComment-394905 Share on other sites More sharing options...
tahj Posted November 20, 2007 Author Share Posted November 20, 2007 Thanks. I will try to work that into the coding. Link to comment https://forums.phpfreaks.com/topic/78024-need-help-with-doing-this-part-of-the-file/#findComment-395150 Share on other sites More sharing options...
tahj Posted December 9, 2007 Author Share Posted December 9, 2007 Ok, this is what I got so far: Here is the HTML part of the program: <!DOCTYPE html PUBLIC "-w3c/DTD xhtml 1.0 Transitional//EN" "http://w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Airline Survey</title></head> <body> <form action="Project.php" method="POST"> <table border="2" bgcolor= "#FFFF99"> <tr> <td colspan="3" align="center"><h2>AIRLINE SURVEYS</h2></td> </tr> <tr> <td>FLIGHT #: <input type="text" name="Flight"> Date: <input type="text" name="Date"> TIME: <input type="text" name="Time"></td> </tr> <tr> <td colspan="3">a. Friendliness of customer staff<br /> <input type ="radio" name="FriendlinessRad" value="Excellent">Excellent<br /> <input type ="radio" name="FriendlinessRad" value="Good">Good<br /> <input type ="radio" name="FriendlinessRad" value="Fair">Fair<br /> <input type ="radio" name="FriendlinessRad" value="Poor">Poor<br /> <input type ="radio" name="FriendlinessRad" value="No Opinion">No Opinion<br /> </td> </tr> <tr> <td colspan="3">b. Space for luggage Storage<br /> <input type ="radio" name="SpaceRad" value="Excellent">Excellent<br /> <input type ="radio" name="SpaceRad" value="Good">Good<br /> <input type ="radio" name="SpaceRad" value="Fair">Fair<br /> <input type ="radio" name="SpaceRad" value="Poor">Poor<br /> <input type ="radio" name="SpaceRad" value="No Opinion">No Opinion<br /> </td> </tr> <tr> <td colspan="3">c. Comfort of seating<br /> <input type ="radio" name="ComfortRad" value="Excellent">Excellent<br /> <input type ="radio" name="ComfortRad" value="Good">Good<br /> <input type ="radio" name="ComfortRad" value="Fair">Fair<br /> <input type ="radio" name="ComfortRad" value="Poor">Poor<br /> <input type ="radio" name="ComfortRad" value="No Opinion">No Opinion<br /> </td> </tr> <tr> <td colspan="3">d. Cleanliness of aircraft<br /> <input type ="radio" name="CleanlinessRad" value="Excellent">Excellent<br /> <input type ="radio" name="CleanlinessRad" value="Good">Good<br /> <input type ="radio" name="CleanlinessRad" value="Fair">Fair<br /> <input type ="radio" name="CleanlinessRad" value="Poor">Poor<br /> <input type ="radio" name="CleanlinessRad" value="No Opinion">No Opinion<br /> </td> </tr> <tr> <td colspan="3">e. Noise level of aircraft<br /> <input type ="radio" name="NoiseRad" value="Excellent">Excellent<br /> <input type ="radio" name="NoiseRad" value="Good">Good<br /> <input type ="radio" name="NoiseRad" value="Fair">Fair<br /> <input type ="radio" name="NoiseRad" value="Poor">Poor<br /> <input type ="radio" name="NoiseRad" value="No Opinion">No Opinion<br /> </td> </tr> <tr> <td colspan="3" align="center"><input type="submit" value="Submit">   <input type="reset" value="Clear Form">   <input type="button" value="View Past Survey"></td> </tr> </form> </body> </html> This part is the php/mySQL coding that needs some work: <!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Strict //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml -strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title></title></head> <body> <?php //connecting to the MySQL server $connectdB = @mysqli_connect("localhost", "flights", "security") or die ("<h2>No Connection established</h2>" . "Error code ". mysqli_connect_errno($connectdB) . ": ". mysqli_connect_error($connectdB) . "</p>"); echo "<p>Connection established</p>"; //selecting the database cs609students $dbname = "flightsurvey"; $selectdb = @mysqli_select_db($connection,$dbname) or die ("<p>Database not selected. " . " The error number " . mysqli_errno($connection) . " means " . mysqli_error($connection) . "</p>"); echo "<p>Database flightsurvey has been selected.</p>"; //inserting records into the file $insertsurvey = "insert into survey_table values ("Flight #", 'United Airlines', "Date")"; $insertresult = mysqli_query($connectdB, $insertsurvey) or die ("<p>Please rate your recent flight experience"); echo "<p>A record has been added to its own file"; $afile = "survey.txt"; file_put_contents($dbname,$afile); //closing the file fclose($afile); file = file_get_contents("survey.txt"); Echo $afile; ?> </body> </html> I need help with programming it to create a new file every time a new survey is made when someone clicks the submit button, and how to view past submitted surveys. Is what I have so far correct? Link to comment https://forums.phpfreaks.com/topic/78024-need-help-with-doing-this-part-of-the-file/#findComment-410081 Share on other sites More sharing options...
tahj Posted December 10, 2007 Author Share Posted December 10, 2007 Can someone check my code please. Link to comment https://forums.phpfreaks.com/topic/78024-need-help-with-doing-this-part-of-the-file/#findComment-410593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.