Jump to content

ZeroShade

Members
  • Posts

    186
  • Joined

  • Last visited

ZeroShade's Achievements

Member

Member (2/7)

0

Reputation

  1. I'm having trouble retrieving data from the database. basically this is what I have to do...use a subquery and find all the employs names and salaries (over the entire company) that earn more tha the average salary of the research department.The main table is called emp and it contains a column called sal. There is another table called dept and it contains a column called dname.This is what I come up with but it doesn't work... SELECT ename, salFROM empWHERE sal > (SELECT AVG(sal) FROM dept WHERE dname='RESEARCH');commit; Does anybody see the problem?
  2. ZeroShade

    AAAhhhhhh

    I can't get this to work at all!! So frustrated. I don't want the user to enter any values but numbers... ctype_digit only gives me and noone else errors. So i'm using is_integer... can somebody figure it out? <!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" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> <title>Passenger Train</title> </head> <body> <h1>Passenger Train</h1> <h2>Calculate Time</h2> <p />This service allows you to calculate the time it will take to reach your destination on our Passenger Train's. Please enter the distance you will be travelling, how many stops will occur, and if there is good or bad weather. You may use this service as many times as you wish. Have fun! <form action="PassengerTrain.php" method="post"> <?php $speed = 50; $weatherDecrease = 40; $stop = 60 - ($numberOfStops * 5); $miles = is_integer($_POST['miles']); $numberOfStops = is_integer($_POST['numberOfStops']); $weather = ($_POST['weather']); $seconds = 60; $minutes = $seconds / 60; $hour = $minutes / 60; if(isset($_POST['submit'])) { if($miles == "" || $numberOfStops == "") echo "<p />Please fill in your information appropriately. Values must be numeric."; else { if($weather == '1') $result = $stop * $miles / $speed; else if($weather == '2') $result = $stop * $miles / $weatherDecrease; } } echo "<p />Miles:<input type='text' name='miles' value='' size='1' maxlength='3' />"; echo "<p />Number of stops:<input type='text' name='numberOfStops' value='' size='1' maxlength='3' />"; echo "<p />Good weather:<input type='radio' name='weather' value='1' checked='checked' />"; echo "<p />Bad weather:<input type='radio' name='weather' value='2' />"; echo "<input type='submit' value='Calculate Time' name='submit' />"; echo $result; ?> </form> <img src="train.jpg" alt="" /> </body></html>
  3. ZeroShade

    bcdiv

    That makes more sense... thanks!
  4. ZeroShade

    bcdiv

    I have a php page that will simply take some information from the user and output the time it will take for the train to travel the specified distance. But if the answer 2.5 is printed... it really means 2 hours and 30 minutes. I understand that the bcdiv can fix this somehow? Any ideas as to how to use it with what I have? <!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" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> <title>Passenger Train</title> </head> <body> <h1>Passenger Train</h1> <h2>Calculate Time</h2> <p />This service allows you to calculate the time it will take to reach your destination on our Passenger Train's. Please enter the distance you will be travelling, how many stops will occur, and if there is good or bad weather. You may use this service as many times as you wish. Have fun! <form action="PassengerTrain.php" method="post"> <?php $speed = 50; $weatherDecrease = 40; $stop = 60 - ($numberOfStops * 5); $miles = ($_POST['miles']); $numberOfStops = ($_POST['numberOfStops']); $weather = ($_POST['weather']); if(isset($_POST['submit'])) { if(ctype_digit($miles) != true || ctype_digit($numberOfStops) != true) echo "<p />Please fill in your information appropriately. Values must be numeric."; else { if($weather == '1') $result = $stop * $miles / $speed; else if($weather == '2') $result = $stop * $miles / $weatherDecrease; // divide 70 miles by 50 speed... minutes equals result - trimmed result * 60 //bcdiv(string $left_operand, string, string $right_operand [, int $scale]) } } echo "<p />Miles:<input type='text' name='miles' value='' size='1' maxlength='3' />"; echo "<p />Number of stops:<input type='text' name='numberOfStops' value='' size='1' maxlength='3' />"; echo "<p />Good weather:<input type='radio' name='weather' value='1' checked='checked' />"; echo "<p />Bad weather:<input type='radio' name='weather' value='2' />"; echo "<input type='submit' value='Calculate Time' name='submit' />"; echo $result; ?> </form> <img src="train.jpg" alt="" /> </body></html>
  5. Not only do I have this problem... but I can't figure out how to transfer the hours into minutes as well... if it prints 2.5 I want it to say 2 hours and 30 minutes, how would I go about doing this with the modulus operator?
  6. I don't get an error if use either of the two, but it doesn't skip to the else statement no matter what. So if its filled out correctly, it still doesn't work.
  7. I did this and I get this error... Fatal error: Call to undefined function: ctype_digit() in /Users/100075255/Sites/PassengerTrain.php on line 21
  8. Another question... I know that ctype_digit($var) will keep users from entering characters other then digits.. but how would I input that into my code... I tried, and I got it wrong? <!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" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Passenger Train</title> </head> <body> <form action="PassengerTrain.php" method="post"> <?php $speed = 50; $weatherDecrease = 40; $stop = 60 - $numberOfStops * 5); $miles = ($_POST['miles']); $numberOfStops = $_POST['numberOfStops']; if(isset($_POST['submit'])) { if($miles == "" || $numberOfStops == "") echo "<p />Please fill in your information appropriately."; else { if($_POST['weather'] == '1') $result = $stop * $miles / $speed; else if($_POST['weather'] == '2') $result = $stop * $miles / $weatherDecrease; } } echo "<p />Miles:<input type='text' name='miles' value='' size='1' maxlength='3' />"; echo "<p />Number of stops:<input type='text' name='numberOfStops' value='' size='1' maxlength='3' />"; echo "<p />Good weather:<input type='radio' name='weather' value='1' checked='checked' />"; echo "<p />Bad weather:<input type='radio' name='weather' value='2' />"; echo "<input type='submit' value='OK' name='submit' />"; echo $result; ?> </form> </body></html>
  9. Now I feel dumb... I forgot the code . <!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" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Passenger Train</title> <!-- 60 x miles รท speed = T --> </head> <body> <form action="PassengerTrain.php" method="post"> <?php $speed = 50; $weatherDecrease = 40; $stop = 60 - ($numberOfStops * 5); $miles = ($_POST['miles']); $numberOfStops = $_POST['numberOfStops']; if(isset($_POST['submit'])) { if($miles == "" || $numberOfStops == "") echo "<p />Please fill in your information appropriately."; else { if(isset($_POST['weather']) == '1') $result = $stop * $miles / $speed; else if(isset($_POST['weather']) == '2') $result = $stop * $miles / $weatherDecrease; } } echo "<p />Miles:<input type='text' name='miles' value='' size='1' maxlength='3' />"; echo "<p />Number of stops:<input type='text' name='numberOfStops' value='' size='1' maxlength='3' />"; echo "<p />Good weather:<input type='radio' name='weather' value='1' checked='checked' />"; echo "<p />Bad weather:<input type='radio' name='weather' value='2' />"; echo "<input type='submit' value='OK' name='submit' />"; echo $result; ?> </form> </body></html>
  10. Why won't my else if statement execute for my second radio button?
  11. I always seem to forget about isset.
  12. How can I say if(click on submit button){this happens!}??
  13. When the form is submitted with everything filled out... it won't print out the info() function... well... it does but without the stored information... why is this? <!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" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>CompuDeal</title> <link rel="stylesheet" href="styles.css" type="text/css" /> </head> <body> <h1>CompuDeal</h1> <div id="text"> <p />Welcome to CompuDeal! Please fill out the form below to order a computer product. Our form is simple and fool proof to use. And our prices are the cheapest ever! </div> <form action="submit.php" method="post"> <fieldset id="personal"> <legend>Personal Information</legend> <h3>Please fill in your shipping information</h3> <label>First Name:</label><input type="text" name="fName" id="fName" /> <br /><label>Last Name:</label><input type="text" name="lName" id="lName" /> <br /><label>Address:</label><input type="text" name="address" id="address" /> <br /><label>City:</label><input type="text" name="city" id="city" /> <br /><label>Province/State:</label><input type="text" name="province" id="province" /> <br /><label>Country: </label><input type="text" name="country" id="country" /> <br /><label>Postal/Zip Code:</label><input type="text" name="postal"id="postal" /> <br /><label>Phone Number:</label><input type="text" name="number" id="number" /> </fieldset> <fieldset id="specs"> <legend>Computer Specs</legend> <h3>Please select your computer parts</h3> <p />PC = $500, Notebook = $700, Workstation = $800 <p />Computer: <select name="computer" id="computer"> <option value="c1">PC</option> <option value="c2">Notebook</option> <option value="c3">Workstation</option> </select> <p />Speed: <select name="proc" id="proc"> <option value="$a188">AMD Athlon 1.88GHz</option> <option value="$a200">AMD Athlon 2.00GHz</option> <option value="$t220">AMD Turion 2.20GHz</option> <option value="$o188">AMD Opteron 1.88GHz</option> <option value="$o200">AMD Opteron 2.00GHz</option> </select> <p />Memory: <select name="memory"> <option value="m1">512MB</option> <option value="m2">1GB</option> <option value="m3">2GB</option> </select> <p />Space: <select name="space"> <option value="h1">80GB</option> <option value="h2">160GB</option> <option value="h3">320GB</option> </select> <p />Color: <select name="color"> <option value="color1">Black</option> <option value="color2">Clear</option> <option value="color3">Blue</option> </select> <p />Quantity: <input type="text" name="quantityNumber" value="1" size="1" maxlength="3" /> <p />All computers are fully loaded and have NVIDIA 7900 GS 256MB graphic cards. </fieldset> <fieldset id="payment"> <legend>Payment Details</legend> <h3>Please select payment methods</h3> <p />Shipping Method: <select name="ship"> <option value="express">Express Shipping</option> <option value="fedex">Fedex</option> <option value="airmail">Airmail</option> </select> <p />Payment Method: <select name="pay"> <option value="masterCard">MasterCard</option> <option value="visa">Visa</option> <option value="electronic">Electronic</option> <option value="cheque">Cheque</option> </select> <input type="submit" value="Place Order!" id="submit" /> </fieldset> </form> <div id="pic"> <img src="pics/computer.gif" alt="" /> </div> </body></html> <!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=iso-8859-1" /> <title>CompuDeal Order</title> <link rel="stylesheet" href="styles.css" type="text/css"> </head> <body> <?php $fName = $_POST['fName']; $lName = $_POST['lName']; $address = $_POST['address']; $city = $_POST['city']; $province = $_POST['province']; $country = $_POST['country']; $postal = $_POST['postal']; $number = $_POST['number']; $computer = $_POST['computer']; $proc = $_POST['proc']; $memory = $_POST['memory']; $space = $_POST['space']; $color = $_POST['color']; $quantityNumber = $_POST['quantityNumber']; $ship = $_POST['ship']; $pay = $_POST['pay']; $day = date + 7; if(empty($fName)) echo "<p />Please fill in your first name."; if(empty($lName)) echo "<p />Please fill in your last name."; if(empty($address)) echo "<p />Please fill in your address."; if(empty($city)) echo "<p />Please fill in your city."; if(empty($province)) echo "<p />Please fill in your province."; if(empty($country)) echo "<p />Please fill in your counrty."; if(empty($postal)) echo "<p />Please fill in your postal/zip code."; if(empty($number)) echo "<p />Please fill in your phone number."; if(empty($quantityNumber) || $quantityNumber == 0) echo "<p />Please fill in your quantity."; if(!empty($fName) && !empty($lName) && !empty($address) && !empty($city) && !empty($province) && !empty($country) && !empty($postal) && !empty($number) && (!empty($quantityNumber) || $quantityNumber > 0)) echo info(); function info() { echo "<p />Thank you for purchasing from CompuDeal! This is your order."; echo "<br />Your personal information is:"; echo "<ul><li>", $fName, "</li><li>", $lName, "</li><li>", $address, "</li><li>", $city, "</li><li>", $province, "</li><li>", $country, "</li><li>", $postal, "</li><li>", $number, "</li></ul>"; echo "<br />Your computer information is:"; echo "<br /><ul><li>", $computer, "</li><li>", $proc, "</li><li>", $memory, "</li><li>", $space, "</li><li>", $color, "</li><li>", $quantityNumber, "</li></ul>"; echo "<br />Your shipping information is:"; echo "<ul><li>", $ship, "</li><li>", $pay, "</li></ul>"; echo "<br />The price including GST & PST is:"; if($computer == "PC") echo "$", ((500 * $quantityNumber) * (1.06 + 1.08)); else if($computer == "Notebook") echo "$", ((700 * $quantityNumber) * (1.06 + 1.08)); else if($computer == "Workstation") echo "$", ((800 * $quantityNumber) * (1.06 + 1.08)); echo "<p />You can expect your new computer on ", $day; echo "<h1>Thank You for shopping with us!!</h1>"; } ?> </body></html>
×
×
  • Create New...