I've created a HTML ZIP code select menu. I've imported a zipcode sql file to my database. ZIP code options are populated using php and mysql select query. Everything works fine. But it's taking too long to load. There are 42741 zips in US.Is there any way to reduce its loading time?
Code is given below..
<select name="zips[]">
<option value=""></option>
<?php
require("db/dbconfig.php");
$result=mysql_query("SELECT * FROM `zipcodes`");
while($row=mysql_fetch_assoc($result)){
?>
<option value="<?php echo $row['ZIP'];?>"><?php echo $row['ZIP'];}?></option>
<?php
?>
ZIP
FROMzipcodes
");. and make index on ZIP field. BTW, I personally agree with @Quentin and I believe getting all 42741 row at once in not a good idea - Samiul Amin Shanto