RE: SELECT * FROM Command *REVISED*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SELECT * FROM tablename WHERE zipcode='$zipcode' ORDER BY entered_date;

Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"
mailto:gary.every@ingramentertainment.com
http://accessingram.com


> -----Original Message-----
> From: Michelle Whelan [mailto:webmaster@dirtjobs.com]
> Sent: Wednesday, March 19, 2003 1:04 PM
> To: php-db@lists.php.net
> Subject:  SELECT * FROM Command *REVISED*
> 
> 
> 
> -Ok, this is what I have.  I hope this is what you are 
> looking for.   I'm looking to format this search results page 
> so that the results come back with the entire entry that also 
> matches the zipcode that was searched.
> 
> ex:  zipcode search = 90210
> 
> results for 90210 are:
> 
> contactname
> 
> phone number
> 
> city
> 
> date posted
> 
> etc. 
> 
> AND, somehow ( I'm thinking ordered list) to have a format 
> for multiple results sorted by date.  
> 
> Is this possible?
> 
> Thanks again in advance
> 
> Michael
> 
> <html>
> <head>
> <title>www..com</title>
> </head>
> 
> <body BACKGROUND="images/dirt.gif" text="#FFFFFF" 
> link="#FFFFFF" vlink="#FFFF00" alink="#FFFF00" BGPROPERTIES="fixed">
> 
> <?
> 
> /* MySQL details */
> $dbHost = "mysql";
> $dbUser = "";
> $dbPass = "";
> $dbName = "";
> $table = "havedirt";
> 
> /* Attempt connection to MySQL server */
> $link = @mysql_connect($dbHost, $dbUser, $dbPass);
> 
> /* If connection wasnt successful... */
> if (!$link)
> {  
>   print ("<b>Error:</b> Could not connect to database.");
>   exit;
> }
> 
> /* Attempt to select our database */
> if (!@mysql_select_db($dbName))
> {
>   print("<b>Error:</b> Could not find $dbName database.");
>   exit;
> }
> 
> $ZipCode = "$_POST["zipcode"]";
> 
> /* Build SQL query to fetch all entries from the table */
> $query = "SELECT * FROM $table WHERE zipcode = "$ZipCode";
> 
> /* Execute query */
> $result = mysql_query($query);
> 
> /* If there was a problem with the query... */
> if (!$result || @mysql_num_rows($result) < 1)
> {
>   print("No entries in table $table.");
>   exit;
> }
>   print("<table>");
>     
> /* For each table entry returned... */
> while($row = mysql_fetch_array($result))
> {
> 
> /* Add details to output variable */
>   print("<tr><td> . $row['zipcode'] . "</td>");
>   print("<tr>");
> 
> }
> 
> print("</table>");
> 
> /* Close link to MySQL */
> mysql_close($link);
> 
> ?>
> 
> </body>
> </html>
> 

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux