Jump to content

My First Webapp - Zipcode Search - Your Suggestion


vinodxx

Recommended Posts

  • 2 weeks later...

I got this from Wicked Cool PHP (William Steinmetz with Brian Ward). I have not tested it yet.

<html><head><style>tr.row1 {    background-color: gray;}tr.row2 {    background-color: white;}</style></head><body><?php $db = mysql_connect("localhost", "username", "password");mysql_select_db("wcphp", $db);function table_row_format(&$row_counter) {    // Returns row class for a row    if ($row_counter & 1) { 	$row_color = "row2";     } else { 	$row_color = "row1";     }    $row_counter++;    return $row_color; }// Sample SQL query$sql = "SELECT product_name FROM product_info";$result = @mysql_query($sql, $db) or die;echo "<table>";$i = 0;while($row = mysql_fetch_array($result)) {    /* print results */    $row_class = table_row_format($i);     echo "<tr class=\"$row_class\"><td>$row[product_name]</td></tr>";}echo "</table>";?></body></html>

If you google it you can quickly get to where you can download the code from the book. Jim

Link to comment
Share on other sites

Turn this into a web service and I'd drop the need to render anything.:)But, if you really want some feedback - plug the longitude and latitude into google maps and plot the location on the map for the person. Embed the information you have in the popup inner html that google maps lets do.Here is an example of what I'm talking about:http://www.deepcreekinns.com/map-popup.cfmAll in all, using a div is gonna produce the quickest results.P.S. I'd only put google ads below the results - not before and after - just makes the app annoying to use, in my opinion.

Link to comment
Share on other sites

I would suggest adding AJAX suggestion thing, so if they misspell something while typing, it will correct suggest a list of possible answers, like if I type in Wisvonsin, a small box should appear underneath the input saying Wisconsin... just a thought. Its pretty cool though, nice job!EDIT: also fix it so if the user inputs a blank string, it tells them to fill in the input instead of an error.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...