문제
사용자로부터 입력을 취하고 다양한 VoIP 서비스를 사용하면 얼마나 많은 돈을 절약 할 수 있는지 추정하는 계산기를 만들려고 노력하고 있습니다.
다음과 같이 설정했습니다.
<form method="get" action="voip_calculator.php">
How much is your monthly phone bill?
<input name="monthlybill" type="text" value="$" size="8">
<p><input type="submit" name="Submit" value="Submit">
</p>
</form>
VoIPCalculator.php에서 내가 가리키는 페이지 인 "MonthlyBill"을 호출하고 싶지만 어떻게 해야하는지 알 수는 없습니다. 또한 행의 숫자에 대한 뺄셈을하는 방법을 알 수 없습니다.
이것은 당신에게 매우 간단 할 수 있지만 그것은 나에게 매우 실망스럽고 약간의 도움을 요청하고 있습니다. 고맙습니다!
다음은 VoIP_Calculator의 관련 사항이 있습니다. URL을 클릭하고 번호를 제출하여 (in) 작업을 볼 수 있습니다. 나는 성공없이 그것을 부르기 위해 다양한 시간을 시도했다.
<table width="100%;" border="0" cellspacing="0" cellpadding="0"class="credit_table2" >
<tr class="credit_table2_brd">
<td class="credit_table2_brd_lbl" width="100px;">Services:</td>
<td class="credit_table2_brd_lbl" width="120px;">Our Ratings:</td>
<td class="credit_table2_brd_lbl" width="155px;">Your Annual Savings:</td>
</tr>
Your monthly bill was <?php echo 'monthlybill' ?>
<?php echo "$monthlybill"; ?>
<?php echo "monthlybill"; ?>
<?php echo '$monthlybill'; ?>
<?php echo 'monthlybill'; ?>
<?php
$monthybill="monthlybill";
$re=1;
$offer ='offer'.$re.'name';
$offername= ${$offer};
while($offername!="") {
$offerlo ='offer'.$re.'logo';
$offerlogo=${$offerlo};
$offerli ='offer'.$re.'link';
$offerlink=${$offerli};
$offeran ='offer'.$re.'anchor';
$offeranchor=${$offeran};
$offerst ='offer'.$re.'star1';
$offerstar=${$offerst};
$offerbot='offer'.$re.'bottomline';
$offerbottomline=${$offerbot};
$offerca ='offer'.$re.'calcsavings';
$offercalcsavings=${$offerca};
echo '<tr >
<td >
<a href="'.$offerlink.'" target="blank">
<img src="http://www.nextadvisor.com'.$offerlogo.'" alt="'.$offername.'" />
</a>
</td>
<td >
<span class="rating_text">Rating:</span>
<span class="star_rating1">
<img src="IMAGE'.$offerstar.'" alt="" />
</span>
<br />
<div style="margin-top:5px; color:#0000FF;">
<a href="'.$offerlink.'" target="blank">Go to Site</a>
<span style="margin:0px 7px 0px 7px;">|</span>
<a href="'.$offeranchor.'">Review</a>
</div>
</td>
<td >'.$offercalcsavings.'</td>
</tr>';
$re=$re+1;
$offer ='offer'.$re.'name';
$offername= ${$offer};
}
?>
OfferCal (1,2,3,4,5,6,7) 저축은 values.php라는 파일로 전화를 걸어 다음과 같이 정의됩니다.
$offer1calcsavings="24.99";
$offer2calcsavings="20.00";
$offer3calcsavings="21.95";
$offer4calcsavings="23.95";
$offer5calcsavings="19.95";
$offer6calcsavings="23.97";
$offer7calcsavings="24.99";
해결책
QueryString에서 값을 가져 와서 PHP 변수에 넣어야합니다.
이와 같이:
$monthlyBill = $_GET['monthlybill'];
이제 변수 $ monthlybill에는 쿼리 스트링의 값이 포함되어 있습니다.
표시하려면 :
echo "Your monthly bill is: $monthlyBill";
다른 팁
내가하는 한 가지는 이것입니다
echo "<pre>";
print_r($_GET);
echo "</pre>";
이것을 당신의 수신 종료에 어딘가에두면 무슨 일이 일어나고 있는지 이해하게 될 것입니다.
대답을 위해 세부 사항이 충분하지 않지만 단순화하고 당신이 배열에 '저축'숫자를 가지고 있다고 가정합시다. 따라서 사용자가 지정한 값에서 각각을 빼야합니까? 당신은 무언가를 부를 필요가 없습니다 (원한다면 할 수 있습니다 ...)
사용자가 '제출'을 클릭하고 페이지가 다시로드되면 월간 빌을 var eG로 다시 당깁니다.
$monthlyBill = $_GET['monthlybill']; //you should do some checking to prevent attacks but that's another matter
그런 다음 저축 목록을 구축 할 때는 다음과 같이 보일 것입니다.
<?php
//...code for the rest of the page and starting your table
foreach($companySavings as $savings){//insert each row into the table
echo("<tr><td>".(comapnyName/Image whatever..)."</td><td>$".$monthlyBill-$savings."</td></tr>);
}
//... end the table and rest of code
?>