我有一个汽车库存网站,我们都知道汽车的差异很大。所以我制作了一个包含最常见属性的表格,它包括复选框、收音机和文本现在我需要检查每一个,我不知道是否适合每一个的 if 语句,因为我想我可以输入三种类型将它们分组在同一个 for 循环中,但我不知道如何执行此操作,或者是否有更好的方法?
<h3>Add a vehicle</h3>
<form action="" method="post" enctype="multipart/form-data" >
<b>VIN: <input type="text" name="vin">
<button class="btn-success"><a style="color: white;" href="#">Decode Vin</a></button><br />
Year: <?php include 'admin/tool/caryears.php'; ?>
Make: <?php include 'admin/tool/carmakes.php'; ?>
Model: <input type="text" name="model"><br />
Mileage: <input type="text" name="mileage"><br />
Price: <input type="text" name="price"><br />
VIN: <input type="text" name="vin"><br />
Attribute: <input type="text" name="att1">
Attribute: <input type="text" name="att2"><br />
Attribute: <input type="text" name="att3">
Attribute: <input type="text" name="att4"><br />
<table border="1" bordercolor="FFCC00" style="background-color:FFFFCC" width="100%" cellpadding="3" cellspacing="3">
<center>
<b>Common Attributes</b>
<tr>
<th>Body style</th>
<td>SUV <input value="suv" name="bodystyle" type="radio"></td>
<td>Sedan <input value="sedan" name="bodystyle" type="radio"></td>
<td>Truck <input value="truck" name="bodystyle" type="radio"></td>
<td>Mini Van <input value="minivan" name="bodystyle" type="radio"></td>
<td>Convertible <input value="convertible" name="bodystyle" type="radio"></td>
<td>Coupe <input value="coupe" name="bodystyle" type="radio"></td>
</tr><tr><td></td>
<td>Hatchback <input value="hatchback" name="bodystyle" type="radio"></td>
<td>Hybrid <input value="hybrid" name="bodystyle" type="radio"></td>
<td>Diesel <input value="diesel" name="bodystyle" type="radio"></td>
<td>Crossover <input value="crossover" name="bodystyle" type="radio"></td>
</tr>
<tr>
<th>Engine and Performance</th>
<td>Engine Size <input name="enginesize" type="text" value=" L" class="input-small"></td>
<td>Cylinders <select name="cyl" class="input-small"><option>Select</option><?php $i=2; while($i<13){echo '<option value="cyl'.$i.'">'.$i.' Cylinders</option>'; $i++;}?></select></td>
<td>Horse Power <input name="hp" class="input-small" type="text"></td>
<td>Diesel <input value="diesel" name="fuel" type="radio"></td>
<td>Gasoline <input value="gasoline" name="fuel" type="radio"></td>
</tr>
<tr>
<tr>
<th>Transmission</th>
<td>Automatic <input value="automatic" name="transmission" type="radio"></td>
<td>Manual <input value="manual" name="transmission" type="radio"></td>
<td>4 Speed <input value="fourspeed" name="shifts" type="radio"></td>
<td>5 Speed <input value="fivespeed" name="shifts" type="radio"></td>
<td>6 Speed <input value="sixspeed" name="shifts" type="radio"></td>
<td>OverDrive <input name="od" type="checkbox"></td>
</tr>
<tr>
<th>Sound System</th>
<td>CD Player <input value="cd" name="sound" type="radio"></td>
<td>MP3 Player <input value="mp3" name="sound" type="radio"></td>
<td>DVD Player <input value="dvd" name="sound" type="radio"></td>
<td>GPS Nav <input name="gps" type="checkbox"></td>
<td>Brand: <input name="sound_system" type="text" class="input-small"></td>
<td>Satellite Radio <input name="sradio" type="checkbox"></td>
</tr>
<tr>
<th>Instrumentation</th>
<td>Tachometer <input name="tachometer" type="checkbox"></td>
<td>Clock <input name="clock" type="checkbox"></td>
<td>Trip Computer <input name="trip" type="checkbox"></td>
<td>Exterior-Weather <input name="eweather" type="checkbox"></td>
<td>All-Digital <input name="digitalboard" type="checkbox"></td>
</tr>
<tr>
<th>DriveTrain</th>
<td>Rear-wheel-drive <input value="rwd" name="drive" type="radio"></td>
<td>Front-wheel-drive <input value="fwd" name="drive" type="radio"></td>
<td>All-wheel-drive <input value="awd" name="drive" type="radio"></td>
<td>4x4 <input name="fxf" type="checkbox"></td>
<td>Cruise Control <input name="cruisecontrol" type="checkbox"></td>
<td>Tilt Steering <input name="tiltsteering" type="checkbox"></td>
</tr>
<tr>
<th>Inside and outside</th>
<td>A/C <input name="ac" type="checkbox"></td>
<td>Removable Top <input name="removabletop" type="checkbox"></td>
<td>Keyless <input name="keyless" type="checkbox"></td>
<td>AirBags <input name="airbags" type="checkbox"></td>
<td>Alloy Wheels <input name="alloy" type="checkbox"></td>
<td>Trunk anti-trap <input name="trunkantitrap" type="checkbox"></td>
</tr>
<tr>
<th>Electric Powered Options</th>
<td>Power Windows <input name="ewindows" type="checkbox"></td>
<td>Power Mirrors <input name="emirrors" type="checkbox"></td>
<td>Power Driver Seat <input name="eseat" type="checkbox"></td>
<td>Power Locks <input name="elocks" type="checkbox"></td>
<td>Vehicle Anti-theft <input name="antitheft" type="checkbox"></td>
<td>LED headlights <input name="ledheadlights" type="checkbox"></td>
</tr>
</table>
</form>
所以我需要检查每一个,如果它不为空或选中或选中,则创建一个数组。
我个人认为我做错了什么,有没有更好的方法来解决这个问题?
我基本上需要这些信息才能将其输入属性数据库