This might help. It is some of the first stuff I ever wrote in PHP so no laughing!
$zip_short = substr($zipcode, 0, 3); //$zipcode is value from submitted form below
$wild = "%%"; //wildcard characters for mysql search
$zip = $zip_short . $wild; //combine first three chars of zip with two wild cards e.g. 902%% so that mysql will match all zips that start with 902, but not match things lik 89021.
//formulate the SQL query
$query = "SELECT company,address,address2,city,state,zip,phone,powerbones,hipaction,email,url FROM locator where zip like '$zip' order by city";
//run the query on the database
$result = mysql_db_query($db, $query, $connection) or die ("Error in Query");
//just to check the actual query for debugging
//print($query);
// check if any data returned from zip_search form
$num_rows = mysql_num_rows($result);
while($myrow = mysql_fetch_array($result))
{
$company = $myrow["company"];
$address = $myrow["address"];
$address2 = $myrow["address2"];
$city = $myrow["city"];
$state = $myrow["state"];
$zipco = $myrow["zip"];
$phone = $myrow["phone"];
$email = $myrow["email"];
$url = $myrow["url"];
print("<table border=0 bgcolor=#FFCC99 cellspacing=0 cellpadding=2 align=center width=100%>
<tr bgcolor=#FF9999>
<td colspan=3><b>$company</b></td>
<td rowspan=5 width=10> </td>
<td colspan=2 align=center><b> </b></td>
</tr>
<tr>
<td colspan=3>$address, $address2</td>
<td align=center width=137> </td>
<td align=center width=55><b> </b></td>
</tr>
<tr>
<td width=142>$city,</td>
<td width=48>$state </td>
<td width=116>$zipco</td>
<td align=center width=137> </td>
<td align=center width=55> </td>
</tr>
<tr>
<td colspan=3>$phone</td>
<td align=center width=137> </td>
<td align=center width=55> </td>
</tr>
<tr>
<td colspan=3><a href=$url>$url</a></td>
<td colspan=2>$email</td>
</tr>
</table>
<P>");
}
I cut and pasted some pieces together, so double check.