Я пытаюсь написать функцию, которая ищет значение для страховых платежей на автомобиле. Я вставил таблицу ниже код:Как я могу эффективно написать таблицу поиска в php?
В настоящее время я попробовал:
function interestRate() {
if ((int)$VehicleYear >= 2001) && (int)$VehicleYear <= 2005){
$Term = 24;
if ((int)$CreditScore >= 720){
$InterestRate = 15.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 19.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 22.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 22.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 22.90;
}
}
if ((int)$VehicleYear == 2006){
$Term = 24;
if ((int)$CreditScore >= 720){
$InterestRate = 15.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 18.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 21.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 22.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 22.90;
}
}
if ((int)$VehicleYear == 2007){
$Term = 36;
if ((int)$CreditScore >= 720){
$InterestRate = 15.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 18.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 21.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 22.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 22.90;
}
}
if ((int)$VehicleYear == 2008){
$Term = 36;
if ((int)$CreditScore >= 720){
$InterestRate = 14.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 17.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 21.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 21.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 21.90;
}
}
if ((int)$VehicleYear == 2009){
$Term = 36;
if ((int)$CreditScore >= 720){
$InterestRate = 14.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 17.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 20.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 20.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 20.90;
}
}
if ((int)$VehicleYear == 2010){
$Term = 36;
if ((int)$CreditScore >= 720){
$InterestRate = 14.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 17.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 20.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 20.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 20.90;
}
}
if ((int)$VehicleYear == 2011){
$Term = 42;
if ((int)$CreditScore >= 720){
$InterestRate = 14.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 16.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 19.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 19.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 20.90;
}
}
if ((int)$VehicleYear == 2012){
$Term = 42;
if ((int)$CreditScore >= 720){
$InterestRate = 12.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 15.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 18.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 19.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 19.90;
}
}
if ((int)$VehicleYear == 2013){
$Term = 42;
if ((int)$CreditScore >= 720){
$InterestRate = 12.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 15.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 18.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 18.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 18.90;
}
}
if ((int)$VehicleYear >= 2014){
$Term = 48;
if ((int)$CreditScore >= 720){
$InterestRate = 11.90;
}
elseif ((int)$CreditScore >= 610) || ((int)$CreditScore <= 719) {
$InterestRate = 14.90;
}
elseif ((int)$CreditScore >= 580) || ((int)$CreditScore <= 609) {
$InterestRate = 17.90;
}
elseif ((int)$CreditScore >= 530) || ((int)$CreditScore <= 579) {
$InterestRate = 18.90;
}
elseif ((int)$CreditScore >= 489) || ((int)$CreditScore <= 529) {
$InterestRate = 18.90;
}
}
}
Это и утомительно и просто не работает, когда я пытаюсь использовать $InterestRate
в расчете. Каков наилучший способ приблизиться к этому?
EDIT: Некоторые упомянули использование таблицы SQL. Я не знаю, как это сделать. Но вот мой стол в основном
<table style="undefined;table-layout: fixed; width: 497px">
<colgroup>
<col style="width: 93px">
<col style="width: 73px">
<col style="width: 75px">
<col style="width: 64px">
<col style="width: 64px">
<col style="width: 64px">
<col style="width: 64px">
</colgroup>
<tr>
<th>Vehicle Year</th>
<th>Term</th>
<th>FICO</th>
<th>FICO</th>
<th>FICO</th>
<th>FICO</th>
<th>FICO</th>
</tr>
<tr>
<td></td>
<td></td>
<td>720 +</td>
<td>719-610</td>
<td>609-580</td>
<td>579-530</td>
<td>529-489</td>
</tr>
<tr>
<td>2014-current</td>
<td>48</td>
<td>11</td>
<td>14</td>
<td>17</td>
<td>18</td>
<td>18</td>
</tr>
<tr>
<td>2013</td>
<td>42</td>
<td>12</td>
<td>15</td>
<td>18</td>
<td>18</td>
<td>18</td>
</tr>
<tr>
<td>2012</td>
<td>42</td>
<td>12</td>
<td>15</td>
<td>18</td>
<td>19</td>
<td>19</td>
</tr>
<tr>
<td>2011</td>
<td>42</td>
<td>14</td>
<td>16</td>
<td>19</td>
<td>19</td>
<td>20</td>
</tr>
<tr>
<td>2010</td>
<td>36</td>
<td>14</td>
<td>17</td>
<td>20</td>
<td>20</td>
<td>20</td>
</tr>
<tr>
<td>2009</td>
<td>36</td>
<td>14</td>
<td>17</td>
<td>20</td>
<td>20</td>
<td>20</td>
</tr>
<tr>
<td>2008</td>
<td>36</td>
<td>14</td>
<td>17</td>
<td>21</td>
<td>21</td>
<td>21</td>
</tr>
<tr>
<td>2007</td>
<td>36</td>
<td>15</td>
<td>18</td>
<td>21</td>
<td>22</td>
<td>21</td>
</tr>
<tr>
<td>2006</td>
<td>24</td>
<td>15</td>
<td>18</td>
<td>21</td>
<td>22</td>
<td>22</td>
</tr>
<tr>
<td>2001-2005</td>
<td>24</td>
<td>15</td>
<td>19</td>
<td>22</td>
<td>22</td>
<td>22</td>
</tr>
</table>
Extra o
Ни вы не передавая '$ ssn' и' значения $ VehicleYear' к функции или вы используете 'global'. Как вы получили значения '$ ssn' и' $ VehicleYear' внутри функции? –
О, извините, позвольте мне исправить это – Tendi