Kyle Caudle
New member
i am having trouble getting the ands between the coins to work properly, if someone could help that would be awesome! i am new to php programming.
<html>
<head>
<title>Coins Program</title>
<style>
body {font-family: sans-serif; font-size:x-large;}
</style>
</head>
<body>
<?php
// get the number of quarters and the number of dimes from the querystring
$quarters = $_GET['q'];
$dimes = $_GET['d'];
$nickels = $_GET['n'];
$pennies = $_GET['p'];
// compute the dollar value of these coins
$dollars = (.25 * $quarters) + (.10 * $dimes) + (.05 * $nickels) + (.01 * $pennies);
// and print the result
if (isset($_GET['q']))
{
echo "$quarters quarters";
}
if (isset($quarters) AND ($dimes))
{
echo " and ";
}
if (isset($_GET['d']))
{
echo "$dimes dimes ";
}
if (isset($quarters) OR ($dimes) AND ($nickels))
{
echo " and ";
}
if (isset($_GET['n']))
{
echo "$nickels nickels ";
}
if (isset($quarters) OR ($dimes) AND ($nickels))
{
echo " and ";
}
if (isset($_GET['p']))
{
echo "$pennies pennies ";
}
if ($dollars == 0)
{
echo "Please enter values into the querystring";
}
else
{
echo "is $$dollars";
}
?>
</body>
</html>
<html>
<head>
<title>Coins Program</title>
<style>
body {font-family: sans-serif; font-size:x-large;}
</style>
</head>
<body>
<?php
// get the number of quarters and the number of dimes from the querystring
$quarters = $_GET['q'];
$dimes = $_GET['d'];
$nickels = $_GET['n'];
$pennies = $_GET['p'];
// compute the dollar value of these coins
$dollars = (.25 * $quarters) + (.10 * $dimes) + (.05 * $nickels) + (.01 * $pennies);
// and print the result
if (isset($_GET['q']))
{
echo "$quarters quarters";
}
if (isset($quarters) AND ($dimes))
{
echo " and ";
}
if (isset($_GET['d']))
{
echo "$dimes dimes ";
}
if (isset($quarters) OR ($dimes) AND ($nickels))
{
echo " and ";
}
if (isset($_GET['n']))
{
echo "$nickels nickels ";
}
if (isset($quarters) OR ($dimes) AND ($nickels))
{
echo " and ";
}
if (isset($_GET['p']))
{
echo "$pennies pennies ";
}
if ($dollars == 0)
{
echo "Please enter values into the querystring";
}
else
{
echo "is $$dollars";
}
?>
</body>
</html>