Jump to content

ZeroShade

Members
  • Posts

    186
  • Joined

  • Last visited

Posts posted by ZeroShade

  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. 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>

    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>

  3. 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>

  4. in order to help you show us some code or any error that you get, otherwise how do we know why it's not working :)
    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>

  5. 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>

  6. This is insane... I still can't get it to work... and tired or not... I'm pretty sure its looking the same as to what you have. This is what I have but it's working funny...

    <!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>				<fieldset div id="submit">						<?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'];								$error = "";								if(ctype_alpha($fName) == "")										$error .= "<p />Please fill in your first name.<br />";								if($error == "")										info();								else										echo $error;								function info()								{										echo "<h3>Thank you for Ordering from CompuDeal! Your order has been processed.</h3>";										echo "<h3>Below is a summary of your order:</h3>";								}						?>				</fieldset>		</body></html>

    If fName == "" then the error is executed... and if the fName is anything else like == " " || even "ladida" then no matter what the other statement executes. I'm frustrated.

  7. Seems easy... but its not working... any reasons?

    <!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>				<fieldset div id="submit">						<?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'];								$error = "";								if(ctype_alpha($fName) == $error)										echo "<p />Please fill in your first name.<br />";								if($error == "");					  echo $error;				else					  info();								function info()								{										echo "<h3>Thank you for Ordering from CompuDeal! Your order has been processed.</h3>";										echo "<h3>Below is a summary of your order:</h3>";								}						?>				</fieldset>		</body></html>

  8. The reason the other variables are there is that I don't forget what they are worth later as I have to do more to it... however, its still not giving any variables when the submit is hit, its like it just refreshes?

  9. That code won't tell if they filled anything out, it will only tell if they submitted the form. Since you are using isset, the variables will still be set, they just might be empty. I normally just have a variable that keeps track of errors.
    $errors = "";if ($fname == "")  $errors .= "Please fill in a first name<br>";if ($lname == "")  $errors .= "Please fill in a last name<br>";...if ($errors == ""){  //no errors}else  echo $errors;

    Thats ingenious! :)... things are always this simple... I don't know why I don't clue in?
  10. How can I set my code up so that if the user does not put in anything for last name but there is something in first name... it will still say please go back to put your information in and vice versa. If both are put in and everything is fine... then the order is complete statement is executed? I can only figure out half of it, but the rest I can't get it to work.

    <!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>			<fieldset div id="submit">			<?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'];								if(ctype_alpha($fName) == false)					info();				else					echo "<p />You have missed a piece of information, please go back to fill it in.";				function info()				{					echo "<h3>Thank you for Ordering from CompuDeal! Your order has been processed.</h3>";					echo "<h3>Below is a summary of your order:</h3>";				}			?>				</fieldset>	</body></html>

  11. Because it's not set up right. Post your code.
    thats all of it. :)
    <!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 25miles ÷ 15speed = T -->		</head>		<body>				<form action="PassengerTrain.php" method="POST">						<?php								$averageSpeed = 50;								$weatherDecrease = 10;								$hour = 60;								$stop = $hour - 5;								$miles = $_GET['miles'];								$speed = $_GET['speed'];								$result = $miles + $speed;								echo "<input type='text' name='miles' value='' size='1' maxlength='3' />";								echo "<input type='text' name='speed' value='' size='1' maxlength='3' />";								echo "<input type='submit' value='OK' />";								echo $result;						?>				</form>		</body></html>

×
×
  • Create New...