How do I get the if statement correct in the lines that has it in the program?

Joined
Mar 16, 2023
Messages
1
Reaction score
0
We are encountering problems in the if statements in the program and cannot run it in the local host in the xampp.

<title>Calculate your solar array size</title>
<style>

form{
width:500px;
margin: auto;
padding: 20px;
background: #9E9E9E;
font-size: 20px;
font-family:Verdana;
color: white;
}
select {
font-size:20px;
padding:5px;
background: #607D8B ;
text-align: center;

}
<h3>Enter the kWh used per month:</h3>

80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
810
820
830
840
850
860
870
880
890
900
910
920
930
940
950
960
970
980
990
1000
1100
1200
1300
1400
1500
1600
1700
1800
1900
2000
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
3100
3200
3300
3400
3500
3600
3700
3800
3900
4000
4100
4200
4300
4400
4500
4600
4700
4800
4900
5000
5100
5200
5300
5400
5500
5600
5700
5800
5900
6000
6100
6200
6300
6400
6500
6600
6700
6800
6900
7000
7100
7200
7300
7400
7500

</select>
<h4>Enter the % of Electricity Bill you want to cover:</h4>
<select name="offset">
<option value=5>5%</option>
<option value=10>10%</option>
<option value=15>15%</option>
<option value=20>20%</option>
<option value=25>25%</option>
<option value=30>30%</option>
<option value=35>35%</option>
<option value=40>40%</option>
<option value=45>45%</option>
<option value=50>50%</option>
<option value=55>55%</option>
<option value=60>60%</option>
<option value=65>65%</option>
<option value=70>70%</option>
<option value=75>75%</option>
<option value=80>80%</option>
<option value=85>85%</option>
<option value=90>90%</option>
<option value=95>95%</option>
<option value=100>100%</option>
<option value=105>105%</option>
<option value=110>110%</option>
<option value=115>115%</option>
<option value=120>120%</option>
<option value=125>125%</option>
<option value=130>130%</option>
<option value=135>135%</option>
<option value=140>140%</option>
<option value=145>145%</option>
<option value=150>150%</option>
<option value=155>155%</option>
<option value=160>160%</option>
<option value=165>165%</option>
<option value=170>170%</option>
<option value=175>175%</option>
<option value=180>180%</option>
<option value=185>185%</option>
<option value=190>190%</option>
<option value=195>195%</option>
<option value=200>200%</option>
<option value=205>205%</option>
<option value=210>210%</option>
<option value=215>215%</option>
<option value=220>220%</option>
<option value=225>225%</option>
<option value=230>230%</option>
<option value=235>235%</option>
<option value=240>240%</option>
<option value=245>245%</option>
<option value=250>250%</option>
<option value=255>255%</option>
<option value=260>260%</option>
<option value=265>265%</option>
<option value=270>270%</option>
<option value=275>275%</option>
<option value=280>280%</option>
<option value=285>285%</option>
<option value=290>290%</option>
<option value=295>295%</option>
<option value=300>300%</option>
<option value=305>305%</option>
<option value=310>310%</option>
<option value=315>315%</option>
<option value=320>320%</option>
<option value=325>325%</option>
<option value=330>330%</option>
<option value=335>335%</option>
<option value=340>340%</option>
<option value=350>350%</option>
<option value=355>355%</option>
<option value=360>360%</option>
<option value=365>365%</option>
<option value=370>370%</option>
<option value=375>375%</option>
<option value=380>380%</option>
<option value=385>385%</option>
<option value=390>390%</option>
<option value=395>395%</option>
<option value=400>400%</option>
<option value=405>405%</option>
<option value=410>410%</option>
<option value=415>415%</option>
<option value=420>420%</option>
<option value=425>425%</option>
<option value=430>430%</option>
<option value=435>435%</option>
<option value=440>440%</option>
<option value=445>445%</option>
<option value=450>450%</option>
<option value=455>455%</option>
<option value=460>460%</option>
<option value=465>465%</option>
<option value=470>470%</option>
<option value=475>475%</option>
<option value=480>480%</option>
<option value=485>485%</option>
<option value=490>490%</option>
<option value=495>495%</option>
<option value=500>500%</option>

</select><br><br>

<input type="submit" name="submit" value="Click and Calculate:">
</form>

<?php

if(isset($_POST['submit']))
{
$kWh=$_POST['kWh'];

$offsetpercent = 0.0;
$offset = 0.0;
$offsetpercent = $offset / 100;
$offsetpercent = $offsetpercent + 1;

$size=$kWh / 30 / 4.5 * 1.15 * 1.2 * $offsetpercent;

echo '<br> This is the Solar Array Size in kW: </b>';
echo '<br />';
echo $size = number_format($size);
echo '<br />';




$kWh=true;
if ($kWh < 300){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 1kW Solis Single Phase Grid Tie Inverter Unit Price: P16,200";
echo '<br />';
echo "2ND OPTION:.1kW G2 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P24,975.00";
echo '<br />';
echo "OFF GRID INVERTER: 1000W 12V/24V SNAT SOLAR INVERTER Unit Price: P6,075 ";
echo '<br />';
echo "HYBRID INVERTER: 3.6kW DEYE On Grid Hybrid Inverter Unit Price: P60,000";
echo '<br />';
echo "HYBRID OPTION 2: 3kW 48V (HYD3000-ES) SOFAR Hybrid Inverter Unit Price: 71,550";

} elseif ($kWh >= 301 && $kWh < 481){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 2.7kW G3 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P20,250,";
echo '<br />';
echo "2ND OPTION: 3kW (Single MPPT) G2 SOFAR 1Phase Inverter (Grid Tie) Unit Price: P32,400";
echo '<br />';
echo "3RD OPTION: 3.3KW G3 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P22,275";
echo '<br />';
echo " 4TH OPTION: 1.6Kw G2 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P27,675 ";
echo '<br />';
echo "OFF GRID INVERTER: 2000W 12V/24V SNAT SOLAR INVERTER Unit Price: P15,525 ";
echo '<br />';
echo "HYBRID INVERTER: 3.6kW DEYE On Grid Hybrid Inverter Unit Price: P60,000 ";
echo '<br />';
echo "HYBRID OPTION 2: 3kW 48V (HYD3000-ES) SOFAR Hybrid Inverter Unit Price: 71,550";
} elseif ($kWh >= 481 && $kWh < 661){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 2.7kW G3 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P20,250 \n
2ND OPTION: 2.2kW G2 SOFAR 1Phase Inverterr (Grid Tie) Unit Price: 30,375 \n
OFF GRID INVERTER: 3000W 12V/24V/48V SNAT SOLAR INVERTER Unit Price: P16,875 \n
HYBRID INVERTER: 3.6kW DEYE On Grid Hybrid Inverter Unit Price: P60,000 \n
HYBRID OPTION 2: 3kW 48V (HYD3000-ES) SOFAR Hybrid Inverter Unit Price: 71,550";
} elseif($kWh >= 661 && $kWh < 751){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 2.7kW G3 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P20,250 \n
OFF GRID INVERTER: 3000W 12V/24V/48V SNAT SOLAR INVERTER Unit Price: P16,875 \n
HYBRID INVERTER: 3.6kW DEYE On Grid Hybrid Inverter Unit Price: P60,000 \n
HYBRID OPTION 2: 3kW 48V (HYD3000-ES) SOFAR Hybrid Inverter Unit Price: 71,550";
} elseif($kWh >= 751 && $kWh < 901){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 3.3KW G3 SOFAR 1Phase Inverter(Grid Tie), Unit Price: P22,275 \n
2ND OPTION: 3kW (Single MPPT) G2 SOFAR 1Phase Inverterr (Grid Tie) Unit Price: 32,400 \n
3RD OPTION: 3kW (Dual MPPT) G2 Unit Price: 35,100, \n
OFF GRID INVERTER: 3000W 12V/24V/48V SNAT SOLAR INVERTER Unit Price: P16,875 \n
HYBRID INVERTER: 3.6kW DEYE On Grid Hybrid Inverter Unit Price: P60,000 \n
HYBRID OPTION 2: 3kW 48V (HYD3000-ES) SOFAR Hybrid Inverter Unit Price: 71,550";
} elseif($kWh >= 901 && $kWh < 991){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 3.3KW G3 SOFAR 1Phase Inverter(Grid Tie), Unit Price: P22,275 \n
OFF GRID INVERTER: 4000W 24V/48V SNAT SOLAR INVERTER Unit Price: P29,700 \n
HYBRID INVERTER: 5kW DEYE On Grid Hybrid Inverter Unit Price: P70,000 \n
HYBRID OPTION 2: 4kW 48V (HYD3000-ES) Unit Price: 81,000";
} elseif($kWh >= 991 && $kWh < 1201){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 5kW G2 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P36,450 \n
OPTION 2: 5kW (Dual MPPT) Solis Single Phase Grid Tie Inverter Unit Price: P38,475 \n
OFF GRID INVERTER: 4000W 24V/48V SNAT SOLAR INVERTER Unit Price: P29,700 \n
HYBRID INVERTER: 5kW DEYE On Grid Hybrid Inverter Unit Price: P70,000 \n
HYBRID OPTION 2: 4kW 48V (HYD3000-ES) Unit Price: 81,000";
} elseif($kWh >= 1201 && $kWh < 1501){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 5kW G2 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P36,450 \n
OPTION 2: 5kW (Dual MPPT) Solis Single Phase Grid Tie Inverter Unit Price: P38,475 \n
OFF GRID INVERTER: 5000W 24V/48V SNAT SOLAR INVERTER Unit Price: P39,150 \n
HYBRID INVERTER: 5kW DEYE On Grid Hybrid Inverter Unit Price: P70,000 \n
HYBRID OPTION 2: 6kW SOLIS HYBRID Inverter Unit Price: 74,250 \n
HYBRID OPTION 3: 5kW 48V(HYD5000-ES) Unit Price: 86,400";
} elseif($kWh >= 1501 && $kWh < 1801){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 6kW G2 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P37,800 \n
OPTION 2: 6kW (Dual MPPT) Solis Single Phase Grid Tie Inverter Unit Price: P39,150 \n
OFF GRID INVERTER: 6000W 48V SNAT SOLAR INVERTER Unit Price: P41,850 \n
HYBRID INVERTER: 6kW SOLIS HYBRID Inverter Unit Price: 74,250 \n
HYBRID OPTION 2: 6kW 48V(HYD5000-ES) Unit Price: P99,900 \n
HYBRID OPTION 3: 8kW DEYE On Grid Hybrid Inverter Unit Price: P118,750";
} elseif($kWh >= 1801 && $kWh < 2101){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 7.5kW G2 SOFAR 1Phase Inverter(Grid Tie) Unit Price: P40,500 \n
OFF GRID INVERTER: 8000W 48V SNAT SOLAR INVERTER Unit Price: P74,250 \n
HYBRID INVERTER: 8kW DEYE On Grid Hybrid Inverter Unit Price: P118,750";
} elseif($kWh >= 2101 && $kWh < 2401){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 8kW (Dual MPPT) Solis Single Phase Grid Tie Inverter Unit Price: P39,150 \n
OFF GRID INVERTER: 8000W 96V SNAT SOLAR INVERTER Unit Price: P74,250 \n
HYBRID INVERTER: 8kW DEYE On Grid Hybrid Inverter Unit Price: P118,750";
} elseif($kWh >= 2401 && $kWh < 3001){
echo "MINIMUM POWER LOWEST PRICE INVERTER: Single Phase 10kw DEYE Grid Tie Inverter Unit Price: P58,050 \n
OPTION 2: 10kW 220V SOLIS 3-Phase Inverter 220V Delta Unit Price: P85,725 \n
OFF GRID INVERTER: 10kW 96V SNAT SOLAR INVERTER Unit Price: P94,500 \n
HYBRID INVERTER: 16kW DEYE On Grid Hybrid Inverter Unit Price: P220,000";
} elseif($kWh >= 3001 && $kWh < 3301){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 11kW (SOFAR 11KTL-X) SOFAR 3 Phase Inverter 380V WYE Unit Price: P86,400 \n
OFF GRID INVERTER: CONTACT SOLAR COMPANY FOR CUSTOM INSTALLATION.\n
HYBRID INVERTER: 16kW DEYE On Grid Hybrid Inverter Unit Price: P220,000";
} elseif ($kWh >= 3301 && $kWh < 4801){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 20kW (SOFAR 20000TL-G2) SOFAR 3 Phase Inverter 380V WYE Unit Price: P116,640 \n
OFF GRID INVERTER: 20kW 196V SNAT SOLAR INVERTER Unit Price: P324,000 \n
HYBRID INVERTER: 16kW DEYE On Grid Hybrid Inverter Unit Price: P220,000";
} elseif($kWh >= 4801 && $kWh < 6001){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 20kW (SOFAR 20000TL-G2) SOFAR 3 Phase Inverter 380V WYE Unit Price: P116,640 \n
OPTION 2: 20kW 220V SOLIS 3-Phase Inverter 220V Delta Unit Price: 162,000 \n
OFF GRID INVERTER: 20kW 196V SNAT SOLAR INVERTER Unit Price: P324,000 \n
HYBRID INVERTER: CONTACT SOLAR COMPANY FOR CUSTOM INSTALLATION.";
} elseif($kWh >= 6001 && $kWh < 7501){
echo "MINIMUM POWER LOWEST PRICE INVERTER: 25kW 220V SOLIS 3-Phase Inverter 220V Delta Unit Price: 162,000 \n
OFF GRID INVERTER: CONTACT SOLAR COMPANY FOR CUSTOM INSTALLATION. \n
HYBRID INVERTER: CONTACT SOLAR COMPANY FOR CUSTOM INSTALLATION.";
} else {
echo "CONTACT SOLAR COMPANY FOR CUSTOM INSTALLATION.";

}
}
?>

<br />
<br />your text
<br />
<br />
<br />

<img src="new folder/Canadian_Solar.jpg" alt="Solar Panel" >
<img src="new folder/Trina_Solar.jpg" alt="Solar Panel" >
<img src="new folder/Inverter_Solar.jpg" alt="Solar Panel" >
<img src="new folder/jingko_Solar.jpg" alt="Solar Panel" >
<img src="new folder/JinkoMono_Solar.jpg" alt="Solar Panel" >
<img src="new folder/SunriMono_Solar.jpg" alt="Solar Panel" >
<img src="new folder/Sunri_Solarr.jpg" alt="Solar Panel" >


</style>
 
Joined
Sep 4, 2022
Messages
128
Reaction score
16
hello !

when you define "$Kwh = true;" , you kick out all your test if;
It's a 'logical error'.

to help you reduce your code :

PHP:
<?php

$val = 50; // min value
$max = 2500; // max value
$step = 10 ; // step value


$select_tag = "<select name="power">" ;

for( $val ; $val <= $max ; $val +=$step  ){

    $select_tag .= "<option value=\"".$val."\">".$val."</option>" ;
    // .= is 'concatenation operator', all strings built are adding in $select_tag
}
$select_tag .= "</select>" ;

echo $select_tag ;

?>

// by this few lines, you can display a long serial of "select /option /option /option /select"
// with all values needed
 
Joined
Sep 4, 2022
Messages
128
Reaction score
16
another syntax solution about "if()elseif()elseif()else()"

this type of statement are --> hard to read and maintain <--

you can substitute by :

several if with accurate tests condition :

if(){ .... }
if(){ .... }
if(){ .... }
if(){ .... }
if(){ .... }

or with "switch" statement
switch($value)
case n:
// and again
 

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top