helpneed Posted December 9, 2011 Share Posted December 9, 2011 I need to create a web page that stores airline surveys in a MYSQL database. Include fields for the data and time of the flight and other fields. Also include group of radio buttons that allow the user to rate the airline. It should include a view past survey result button on the main survey page that displays a list of past results. I have made two php pasges and a Survey html main page but they don't work. Can anyone please help me?? I need to know what's wrong with my coding!!! THANKS 17170_.php 17171_.php 17172_.php Quote Link to comment https://forums.phpfreaks.com/topic/252799-please-help-me-with-mysql-coding/ Share on other sites More sharing options...
SergeiSS Posted December 9, 2011 Share Posted December 9, 2011 It seems that nobody will load your files... You would better show your code in the forum. Just select and show here the important part of the code. Quote Link to comment https://forums.phpfreaks.com/topic/252799-please-help-me-with-mysql-coding/#findComment-1296063 Share on other sites More sharing options...
Drummin Posted December 9, 2011 Share Posted December 9, 2011 You need to change Surveys.php so radio fields match for each group. Not sure if there are any other issues. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Airline Survey</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> </head> <body> <h2>Please enter the following details</h2> <form method="POST" action="SubmitSurvey.php"> <p>Name <input type="text" name="name" /></p> <p>Age <input type="text" name="age" /></p> <p>Flight Number <input type="text" name="flt_no" /></p> <p>Flight Date <input type="text" name="flt_date" /></p> <p>Flight Time <input type="text" name="flt_time" /></p><br /><br /> <p>Friendliness of customer staff</p><br /> <input type="radio" name="staff" value="No Opinion" />No Opinion<br /> <input type="radio" name="staff" value="Poor" />Poor<br /> <input type="radio" name="staff" value="Fair" />Fair<br /> <input type="radio" name="staff" value="Good" />Good<br /> <input type="radio" name="exc" value="Excellent" />Excellent<br /><br /> <p>Space for luggage storage</p><br /> <input type="radio" name="storage" value="No Opinion" />No Opinion<br /> <input type="radio" name="storage" value="Poor" />Poor<br /> <input type="radio" name="storage" value="Fair" />Fair<br /> <input type="radio" name="storage" value="Good" />Good<br /> <input type="radio" name="storage" value="Excellent" />Excellent<br /><br /> <p>Comfort of seating</p><br /> <input type="radio" name="comfort" value="No Opinion" />No Opinion<br /> <input type="radio" name="comfort" value="Poor" />Poor<br /> <input type="radio" name="comfort" value="Fair" />Fair<br /> <input type="radio" name="comfort" value="Good" />Good<br /> <input type="radio" name="comfort" value="Excellent" />Excellent<br /><br /> <p>Cleanliness of aircraft</p><br /> <input type="radio" name="cleanliness" value="No Opinion" />No Opinion<br /> <input type="radio" name="cleanliness" value="Poor" />Poor<br /> <input type="radio" name="cleanliness" value="Fair" />Fair<br /> <input type="radio" name="cleanliness" value="Good" />Good<br /> <input type="radio" name="cleanliness" value="Excellent" />Excellent<br /><br /> <p>Noise level of aircraft</p><br /> <input type="radio" name="noise" value="No Opinion" />No Opinion<br /> <input type="radio" name="noise" value="Poor" />Poor<br /> <input type="radio" name="noise" value="Fair" />Fair<br /> <input type="radio" name="noise" value="Good" />Good<br /> <input type="radio" name="noise" value="Excellent" />Excellent<br /><br /> <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p> </form> <p><a href="ShowPastResults.php">Show Past Survey Results</a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/252799-please-help-me-with-mysql-coding/#findComment-1296064 Share on other sites More sharing options...
Drummin Posted December 9, 2011 Share Posted December 9, 2011 NOTE: The radio buttons I named "staff" (and I missed one) should be "friendliness" to match SubmitSurvey.php. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Airline Survey</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> </head> <body> <h2>Please enter the following details</h2> <form method="post" action="SubmitSurvey.php"> <p>Name <input type="text" name="name" /></p> <p>Age <input type="text" name="age" /></p> <p>Flight Number <input type="text" name="flt_no" /></p> <p>Flight Date <input type="text" name="flt_date" /></p> <p>Flight Time <input type="text" name="flt_time" /></p><br /><br /> <p>Friendliness of customer staff</p><br /> <input type="radio" name="friendliness" value="No Opinion" />No Opinion<br /> <input type="radio" name="friendliness" value="Poor" />Poor<br /> <input type="radio" name="friendliness" value="Fair" />Fair<br /> <input type="radio" name="friendliness" value="Good" />Good<br /> <input type="radio" name="friendliness" value="Excellent" />Excellent<br /><br /> <p>Space for luggage storage</p><br /> <input type="radio" name="storage" value="No Opinion" />No Opinion<br /> <input type="radio" name="storage" value="Poor" />Poor<br /> <input type="radio" name="storage" value="Fair" />Fair<br /> <input type="radio" name="storage" value="Good" />Good<br /> <input type="radio" name="storage" value="Excellent" />Excellent<br /><br /> <p>Comfort of seating</p><br /> <input type="radio" name="comfort" value="No Opinion" />No Opinion<br /> <input type="radio" name="comfort" value="Poor" />Poor<br /> <input type="radio" name="comfort" value="Fair" />Fair<br /> <input type="radio" name="comfort" value="Good" />Good<br /> <input type="radio" name="comfort" value="Excellent" />Excellent<br /><br /> <p>Cleanliness of aircraft</p><br /> <input type="radio" name="cleanliness" value="No Opinion" />No Opinion<br /> <input type="radio" name="cleanliness" value="Poor" />Poor<br /> <input type="radio" name="cleanliness" value="Fair" />Fair<br /> <input type="radio" name="cleanliness" value="Good" />Good<br /> <input type="radio" name="cleanliness" value="Excellent" />Excellent<br /><br /> <p>Noise level of aircraft</p><br /> <input type="radio" name="noise" value="No Opinion" />No Opinion<br /> <input type="radio" name="noise" value="Poor" />Poor<br /> <input type="radio" name="noise" value="Fair" />Fair<br /> <input type="radio" name="noise" value="Good" />Good<br /> <input type="radio" name="noise" value="Excellent" />Excellent<br /><br /> <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p> </form> <p><a href="ShowPastResults.php">Show Past Survey Results</a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/252799-please-help-me-with-mysql-coding/#findComment-1296068 Share on other sites More sharing options...
helpneed Posted December 9, 2011 Author Share Posted December 9, 2011 thank you so much for your help!!! I made change for my survey html page. Can you please give me an advice for other two pages?? thank you!! here is my submit survey page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Survey Form</title> </head> <body> <?php if(empty($_GET["date"]) || empty($_GET["flight"]) || empty($_GET["time"])) echo "<p>You must enter the date, flight number and departure time! Click your browser's Back button to return to the form.</p>"; else{ $DBConnect = @mysql_connect("localhost", "root", "mgs314"); if($DBConnect === FALSE) echo "<p>Unable to connect to the database server.</p>" . "<p>Error code ".mysql_errno() . ": ".mysql_error()."</p>"; else { $DBName = "airlineSurvey"; if(!@mysql_select_db($DBName, $DBConnect)){ $SQLstring = "CREATE DATABASE $DBName"; $QueryResult = @mysql_querry($SQLstring, $DBConnect); if($QueryResult === FALSE) echo "<p>Unable to execute the query.</p>" . "<p>Error code ".mysql_errno($DBConnect) . ": ".mysql_error($DBConnect) ."</p>"; else echo "<p>You are the first visitor!</p>"; } mysql_select_db($DBName, $DBConnect); $TableName = "airlineSurvey"; $SQLstring = "SHOW TABLES LIKE '$TableName'"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if(mysql_num_rows($QueryResult) == 0){ $SQLstring = "CREATE TABLE $TableName (countID SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY, last_name VARCHAR(40), first_name VARCHAR(40))"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if($QueryResult === FALSE) echo "<p>Unable to create the table.</p>" . "<p>Error code ".mysql_errno($DBConnect) . ": ".mysql_error($DBConnect) ."</p>"; } $Date=stripslashes($_GET["date"]); $FlightNumber=($_GET["flight"]); $DepartureTime=($_GET["time"]); $Friendliness=($_GET["friendliness"]); $Cleanliness=($_GET["cleanliness"]); $Space=($_GET["space"]); $Noise=($_GET["noise"]); $Comfort=($_GET["comfort"]); $QueryResult = @mysql_query($SQLstring, $DBConnect); if($QueryResult === FALSE) echo "<p>Unable to execute the query.</p>" . "<p>Error code ".mysql_errno($DBConnect) . ": ".mysql_error($DBConnect) ."</p>"; else echo "<p>Thank you for completing our survey!</p>"; } mysql_close($DBConnect); } ?> </body> </html> Showpastresults page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Past Survey Results</title> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $DBConnect = @mysqli_connect("localhost", "root", "mgs314") if($DBConnect === FALSE) { echo "<p>Unable to connect to the database server.</p>" . "<p>Error code ".mysql_errno() . ": ". mysql_error()."</p>"; else { $DBName = "airlineSurvey"; if (!@mysqli_select_db($DBConnect, $DBName)) die("<p>There are no past surveys!</p>"); $TableName = "t_survey"; $SQLstring = "SELECT * FROM $TableName"; $QueryResult = @mysqli_query($DBConnect, $SQLstring); if (mysql_num_rows($QueryResult) == 0) echo"<p>There are no passengers!</p>"; else{ echo "<p>The following passengers have completed the survey:</p>"; echo "<table width='100%' border='1'>"; echo "<tr><th>Passenger Name</th></tr>"; $Row = mysqli_fetch_assoc($QueryResult); do { echo "<tr><td>{$Row['psngr_name']}</td></tr>"; $Row = mysqli_fetch_assoc($QueryResult); } while ($Row); $TableName = "t_options"; $SQLstring = "SELECT * FROM $TableName"; $QueryResult = @mysqli_query($DBConnect, $SQLstring); if (mysqli_num_rows($QueryResult) == 0) echo"<p>There are no survey results!</p>"; echo "<p>Survey Results:</p>"; echo "<table width='100%' border='1'>"; echo "<tr><th>Friendliness of customer staff</th><th>Space for luggage storage</th><th>Comfort of seating</th><th>Cleanliness of aircraft</th><th>Noise level of aircraft</th></tr>"; $Row = mysqli_fetch_assoc($QueryResult); do { echo "<tr><td>{$Row['no_op']}</td>"; echo "<td>{$Row['poor']}</td>"; echo "<td>{$Row['fair']}</td>"; echo "<td>{$Row['good']}</td>"; echo "<td>{$Row['exc']}</td></tr>"; $Row = mysqli_fetch_assoc($QueryResult); } while ($Row); mysql_free_result($QueryResult); mysql_close($DBConnect); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/252799-please-help-me-with-mysql-coding/#findComment-1296401 Share on other sites More sharing options...
mikesta707 Posted December 9, 2011 Share Posted December 9, 2011 What exactly is wrong? Just saying something doesn't work makes it difficult for us to help you. Please describe the problem in more detail. I have a blog post which discusses good ways to ask good questions (link in sig I think). Unfortunately I'm on my iPhone currently so I can't go through your whole code block. Quote Link to comment https://forums.phpfreaks.com/topic/252799-please-help-me-with-mysql-coding/#findComment-1296418 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.