Jump to content

nschmutz

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nschmutz's Achievements

Member

Member (2/5)

0

Reputation

  1. Error MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<html> <form action="schmutz_03_05.php" method="POST"> Please select a cus' at line 1 This is the error message I get when running in the phpadmin. Does anyone know what I am doing wrong?
  2. Does anyone know the solution to my problem of being able to display the results?
  3. I am running XAMPP which has Apache and MySql both running. I hope that answers your question conker87.
  4. Nice catch conker87, I made the correction and no errors and it still is not displaying any results.
  5. I was wondering if someone can look at my code and tell me why the results are not displaying. <html> <form action="schmutz_03_05.php" method="POST"> Please select a customer and a clerk: <p>Customer: <select name="customer"></p> <?php //creating the drop down menu with information from the database include ('mysql_connect_to_vandelay.php'); $query = "SELECT customer_id,CONCAT(customer_first_name, ' ',customer_last_name) AS customer_name FROM customers cu"; $result = mysql_query($query); //running query while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<option value=" . $row['customer_id'] . ">" . $row['customer_name'] . "</option>"; } ?> </select> Clerk: <select name="clerk"> <?php include ('mysql_connect_to_vandelay.php'); $query = "SELECT clerk_id, CONCAT(clerk_first_name, ' ', clerk_last_name) AS clerk_name FROM clerks cl"; //make sure you have AS when combined with CONCAT $result = mysql_query($query); //running query while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<option value=" . $row['clerk_id'] . ">" . $row['clerk_name'] . "</option>"; } //end of while statement ?> </select> <?php if (isset($_POST['submitted'])) { include ('mysql_connect_to_vandelay.php'); $sort_by=$_POST['sort_by']; // Build the query $query = "SELECT CONCAT(cu.customer_first_name, ' ', cu.customer_last_name) AS customer_name,CONCAT(cl.clerk_first_name, ' ', cl.clerk_last_name) AS clerk_name,SUM( ROUND(li.item_quantity * li.item_unit_price, 2) ) AS order_total,COUNT( DISTINCT o.order_id ) AS number_of_orders,ROUND(SUM( ROUND(li.item_quantity * li.item_unit_price, 2) ) / COUNT( DISTINCT o.order_id ), 2) AS average_order_total FROM orders o, clerks cl, customers cu, line_items li WHERE o.clerk_id=cl.clerk_id AND o.customer_id=cu.customer_id AND o.order_id=li.order_id AND CONCAT(cu.customer_first_name, ' ', cu.customer_last_name)='Peter Parker' AND CONCAT(cl.clerk_first_name, ' ', cl.clerk_last_name)='George Costanza'GROUP BY clerk_name, customer_name, order_total, number, numer_of_orders;"; //query to display names, total orders, #of orders and average order total $result = @mysql_query ($query); // Print the results echo '<table><tr><td>Customer Name:</td><td>Clerk Name:</td><td>Total of Orders:</td><td>Number of Orders:</td><td>Average order total:</td></tr>'; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<tr><td align="left">'.$row['customer_name'].'</td><td align="left">'.$row['clerk_name'].'</td><td align="left">'.$row['order_total'].'</td><td align="left">'.$row['number_of_orders'].'</td><td align="left">'.$row['average_order_total'].'</td></tr>'; } echo '<tr><td> </td><td> </td></tr> </table>'; } ?> <input type="submit" name="submit" value="List Orders" /> </form> </html> I appreciate any help.
  6. Thanks again Ruzzas. The other thing I was trying to prove in the form is that the number entered needs to be between 1 and 20. I was trying to display the error message. I am not sure where to place the error message or whether to create a loop of some kind. appreciate any help.
  7. Good catch Ruzzas on the </select>. I still have all the results being displayed after the number is submitted. Do you know what my problem is or how I should write the code to make it only enter the selected results. Do you think I need to make a foreach loop or for loop? Here is my updated code from your help: <html> <head> <title>Assignment 2 Question 4</title> </head> <body> <form action="Assgn_2_Q4.php" method="POST"> <select name="entered"/> <option value="Square Root">Square Root</option> <option value="Square">Square</option> <option value="Cube">Cube</option> </select> of <input type="text" name="entered" value="<?php echo $entered; ?>"/><!--making the form sticky--> <input type="submit" name="submit" value="is equal to" /> </form> <?php $entered = $_POST['entered'];//declaring $entered if (isset($_POST['entered'])) { $entered = $_POST['entered']; $root = square_root($entered); echo "The square root of " . $entered . " is " . $root . "<br />"; $entered = $_POST['entered']; $square = square($entered); echo "The square of " . $entered . " is " . $square . "<br />"; $entered = $_POST['entered']; $cube = cube($entered); echo "The square of " . $entered . " is " . $cube . "<br />"; }//end of isset function square_root($n) { $result = round(sqrt($n), 3); return $result; }//end of function function square($n) { $result = pow($n,2); return $result; }//end of function for square function cube($n) { $result = pow($n,3); return $result; }//end of cube function ?> </body> </html>
  8. Thanks Ruzzas, so much. I can now easily read the code and it somewhat makes sense now. I am still having issues trying to get the results to line up with ONLY the selection from the drop-down menu. DO you know how I can correct this problem?
  9. Thanks Ruzzas, I think my other problem is that I make my code more complicated than it needs to be but it is because I have a hard time understanding the logic that needs to be written. Do you know how I can present my code in the correct way and get the form to display the results only from the selection chosen?
  10. I need help making this form operate correctly. First I need help making the form 'sticky'. I feel like I have the right code to make the form sticky but the number entered disappear once you hit the submit button. The other part is I could use help writing the correct code that displays the results based upon the drop-down menus. Right now no matter what is selected the results of all the functions are displayed and I am trying to just get the results from the drop-down selection results. Here is my code: <html> <head> <title>Assignment 2 Question 4</title> </head> <body> <form action="Assgn_2_Q4.php" method="POST"> <select name="entered"/> <option value="Square Root">Square Root</option> <option value="Square">Square</option> <option value="Cube">Cube</option> <h1>of</h1> <input type="text" name="entered" value="<?php $entered; ?>"/> <input type="submit" name="submit" value="is equal to" /> </form> <?php function square_root($n) { $result = round(sqrt($n), 3); return $result; }//end of function $entered = $_POST['entered']; if (isset($_POST['entered'])) { $entered = $_POST['entered']; $root = square_root($entered); echo "The square root of " . $entered . " is " . $root . "</br>"; }//end of isset function square($n) { $result = pow($n,2); return $result; }//end of function for square if (isset($_POST['entered'])) { $entered = $_POST['entered']; $square = square($entered); echo "The square of " . $entered . " is " . $square . "</br>"; }//end of isset for square function cube($n) { $result = pow($n,3); return $result; }//end of cube function if (isset($_POST['entered'])) { $entered = $_POST['entered']; $cube = cube($entered); echo "The square of " . $entered . " is " . $cube . "</br>"; }//end of isset for cube ?> </body> </html> Any help is deeply appreciated!!
  11. I am trying to get the drop down selection to display the results. The user is supposed to choose a start and end year and then after hitting the submit button it is suppose to display the results of the World cup information between the years selected. I got the drop down menus to be sticky but now I cannot get any results to display. Could someone help to point out how to correct my code to display both the error message and the World Cup results? <html> <head> </head> <p>Please enter the start and end years.</p> <form action="schmutz_02_03.php" method="post"> <?php $finals1974 = array('West Germany', 'Netherlands', '2-1', 'West Germany'); $finals1978 = array('Argentina', 'Netherlands', '3-1', 'Argentina'); $finals1982 = array('Italy', 'West Germany', '3-1', 'Argentina'); $finals1986 = array('Argentina', 'West Germnay', '3-2', 'Mexico'); $finals1990 = array('West Germany', 'Argentina', '1-0', 'Italy'); $finals1994 = array('Brazil', 'Italy', '3-2', 'U.S.A.'); $finals1998 = array('France', 'Brazil', '3-0', 'France'); $finals2002 = array('Brazil', 'Germany', '2-0', 'S.Korea.Japan'); $finals2006 = array('Italy', 'France', '5-3', 'Germany'); $start = array('1974', '1978', '1982', '1986', '1990', '1994', '1998', '2002', '2006'); echo 'Start year: <select name="start" value="$start">'; foreach ($start as $key => $value) { if ($key == $_POST['start']) { echo "<option value=\"$key\" selected=\"selected\">$value</option>"; } else { echo "<option value=\"$key\">$value</option>"; } } echo '</select>'; $end = array('1974', '1978', '1982', '1986', '1990', '1994', '1998', '2002', '2006'); echo 'End year: <select name="end" value="$end">'; foreach ($end as $key => $value) { if ($key == $_POST['end']) { echo "<option value=\"$key\" selected=\"selected\">$value</option>"; } else { echo "<option value=\"$key\">$value</option>"; } } echo '</select>'; if (isset( $_POST[ 'year' ] )) { $yearEnt = $_POST['year']; //not sure how to include the $finals array into the $years array $years = array ('1974' => $finals1974, '1978' => $finals1978, '1982' => $finals1982, '1986' => $finals1986, '1990' => $finals1990, '1994' => $finals1994, '1998' => $finals1998, '2002' => $finals2002, '2006' => $finals2006); $remainder = ($yearEnt - 1974) % 4; if(isset($_POST['start']) && isset($_POST['end'])) { $start = $_POST['start']; $end = $_POST['end']; if($end < $start) { echo "End start year should be less than or equal to the end year!</br>"; } for ($i=$_POST['start']; $i <= $_POST['end']; $i = $i + 4) foreach ($years as $key=> $value) { //echo winner for that year if ($key = $i) { echo "The FIFA World Cup champions in $yearEnt were <b>" . $years[$yearEnt][0] . "</b>.\n They beat <b>" . $years[$yearEnt][1] . "</b>, with a score of <b>" . $years[$yearEnt][2] . "</b>.\n The finals were hosted by <b>" . $years[$yearEnt][3] . "</b>.</br>"; } } } } echo '<input type="submit" name="submit" value="Go!" />'; ?> </form> </html>
  12. I am coming up with a syntax error that I cannot figure out. Could someone point out the obvious to me? <html> <head> </head> <p>Please enter the start and end years.</p> <form action="schmutz_02_03.php" method="post"> <?php $finals1974 = array('West Germany', 'Netherlands', '2-1', 'West Germany'); $finals1978 = array('Argentina', 'Netherlands', '3-1', 'Argentina'); $finals1982 = array('Italy', 'West Germany', '3-1', 'Argentina'); $finals1986 = array('Argentina', 'West Germnay', '3-2', 'Mexico'); $finals1990 = array('West Germany', 'Argentina', '1-0', 'Italy'); $finals1994 = array('Brazil', 'Italy', '3-2', 'U.S.A.'); $finals1998 = array('France', 'Brazil', '3-0', 'France'); $finals2002 = array('Brazil', 'Germany', '2-0', 'S.Korea.Japan'); $finals2006 = array('Italy', 'France', '5-3', 'Germany'); if (isset( $_POST[ 'year' ] )) { $yearEnt = $_POST['year']; //not sure how to include the $finals array into the $years array $years = array ('1974' => $finals1974, '1978' => $finals1978, '1982' => $finals1982, '1986' => $finals1986, '1990' => $finals1990, '1994' => $finals1994, '1998' => $finals1998, '2002' => $finals2002, '2006' => $finals2006); $remainder = ($yearEnt - 1974) % 4; if(isset($_POST['start']) && isset($_POST['end'])) { $start = $_POST['start']; $end = $_POST['end']; if($end < $start) { echo "End start year should be less than or equal to the end year!</br>"; } for ($i=$_POST['start']; $i <= $_POST['end']; $i = $i + 4) foreach ($years as $key=> $value) { //echo winner for that year if ($key = $i) { echo "The FIFA World Cup champions in $yearEnt were <b>" . $years[$yearEnt][0] . "</b>.\n They beat <b>" . $years[$yearEnt][1] . "</b>, with a score of <b>" . $years[$yearEnt][2] . "</b>.\n The finals were hosted by <b>" . $years[$yearEnt][3] . "</b>.</br>"; } } } echo 'Start year: <select name="start" value="$start">'; foreach ($start as $key => $value) { if ($key == $_POST['start']) { echo "<option value=\"$key\" selected=\"selected\">$value</option>"; } else { echo "<option value=\"$key\">$value</option>"; } } echo '</select>'; echo 'End year: <select name="end" value"$end">'; foreach ($end as $key => $value) { if ($key == $_POST['end']) { echo "<option value=\"$key\" selected=\"selected\">$value</option>"; } else { echo "<option value=\"$key\">$value</option>"; } } echo '</select>'; echo '<input type="submit" name="submit" value="Go!" />'; ?> </form> </html>
  13. Thanks for that catch of the name Pikachu2000, I made the correction now it does display the results but I need to work on the math problem itself. I just am confused on the logic of how to display the integer divided by 3.
  14. I am trying to display the results of the entered integer is divisible by 3 and have the form be 'sticky'. So far I have no errors but the form is not sticky and I am no getting any results to display.
  15. I'm not sure how to create the code to represent a division problem. Here is what I have so far in the code. <html> <head> </head> <form action="schmutz_extra_01.php" method="POST"> <p>Please enter an integer that is divisible by 3:</p> <input type="text" name="number" value="<?php echo $_POST['integer'];?>"/></p> <input type="submit" name="submit" value="Calculate!" /> </form> <?php function divisible($n) { $result = ($n) % 3; return $result; } if (isset($_POST['integer'])) { $integer = $_POST['integer']; $div = divisible($integer); echo "Your entered " . $integer . " and the result is " . $div . "</br>"; } ?> </html>
×
×
  • 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.