Jump to content

2levelsabove

Members
  • Posts

    180
  • Joined

  • Last visited

    Never

Everything posted by 2levelsabove

  1. Automotive site in which users are searching by make model and zipcode. session_start(); //to store session variables require_once('include/_process/application.php'); $results=''; $data=array(); $matches=array(); if (isset($_GET['id'])) { $searchQuery ="Select reg_users_ads.reg_users_ads_id, dealer, reg_users_ads.year, make, model, reg_users_ads.trim, reg_users_ads.price, reg_users_ads.exterior_color, reg_users_ads.transmission, reg_users_ads.mileage FROM reg_users_ads, atrMakes, atrModels WHERE dealer=".$_GET['id']." AND reg_users_ads.atrMakesID = atrMakes.atrMakesID AND atrMakes.atrMakesID = atrModels.atrMakesID AND reg_users_ads.atrModelsID=atrModels.atrModelsID"; $skipDistanceCalc=1; } else { //////////////////////////////////distance stuff////////////////////////////////////////// //lets set variables if (isset($_GET['page']))//we are following page links so we must use the page variables { $make=$_POST['makeo']; $model=$_POST['modelo']; $zip=$_POST['USZipcodeo']; $radius=$_POST['radiuso']; } else{ $make=$_POST['make']; $model=$_POST['model']; $zip= $_POST['USZipcode']; $radius = $_POST['radius']; } $query = "select * from atrUSZipcode where ZIPCode = '$zip' LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(empty($row)){$results = "<tr><td align='center' class='results' style='font-size:16px;font-weight:bold;color:red;font-family:arial;'>Invalid zip code</td></tr>";} $lat = $row['lat']; $lon = $row['lon']; /////////////////////////////////////////////////////////// $coords = array('latitude' => "$row[lat]", 'longitude' => "$row[lon]"); $sql = "SELECT ZIPCode, ( 3959 * acos( cos( radians( {$coords['latitude']} ) ) * cos( radians( lat ) ) * cos( radians( lon ) - radians( {$coords['longitude']} ) ) + sin( radians( {$coords['latitude']} ) ) * sin( radians( lat ) ) ) ) AS distance FROM atrUSZipcode HAVING distance <= {$radius} ORDER BY distance"; $result = mysql_query($sql); //we got all the zips within however miles of users zipcode while($row = mysql_fetch_array($result)){ $validZIPS[] = $row['ZIPCode']; $zipDistance[]= $row['distance']; } $comma_separated_zip = implode("','", $validZIPS); $searchQuery ="Select reg_users_ads.reg_users_ads_id, reg_users_ads.year, make, model, reg_users_ads.trim, reg_users_ads.price, reg_users_ads.exterior_color, reg_users_ads.transmission, reg_users_ads.mileage, zipcode "; $searchQuery .= "FROM reg_users_ads, atrMakes, atrModels"; if ($model=="0")//all selected in models { $searchQuery .= " WHERE reg_users_ads.atrMakesID = '".$make."' AND reg_users_ads.atrMakesID = atrMakes.atrMakesID AND reg_users_ads.atrModelsID = atrModels.atrModelsID AND reg_users_ads.zipcode IN ('".$comma_separated_zip."') AND status = 'active'"; } else { $searchQuery .= " WHERE reg_users_ads.atrMakesID = '".$make."' AND reg_users_ads.atrModelsID = '".$model."' AND reg_users_ads.atrMakesID = atrMakes.atrMakesID AND reg_users_ads.atrModelsID = atrModels.atrModelsID AND reg_users_ads.zipcode IN ('".$comma_separated_zip."') AND status = 'active'"; } //error_log($searchQuery,1,"[email protected]"); ////////////////////////////////////////////////////////// //echo $searchQuery; $searchResult = mysql_query($searchQuery); $num_rows=mysql_num_rows($searchResult); if ($num_rows) {//if results while($row = mysql_fetch_array($searchResult)){ $alltheresults[] = $row; } unset($row); //lets add the zipcode distance from user with each row foreach($alltheresults as $row){ if ($skipDistanceCalc==1) {$data[] = $row; } else{ $found=array_search($row[9],$validZIPS); // error_log("found is============================== ".$found,1,"[email protected]"); if ($found!==false) { // error_log("found=".$found,1,"[email protected]"); array_unshift($row,$zipDistance[$found]); $row[0]=round($row[0],2); } $data[] = $row; }//else }//for loop usort($data,compare); /////////////////////////////Page numbering stuff///////////////////////////////// $total_results = mysql_num_rows($searchResult); $limit = "15"; //limit of archived results per page. $total_pages = ceil($total_results / $limit); //total number of pages $page=$_GET['page']; if (empty($page)) { $page = "1"; //default page if none is selected } $offset = ($page - 1) * $limit; //starting number for displaying results out of DB /////////////////////////////////////////////////////////////////////////////// $data2=array_slice($data,$offset, $limit); }//if results } Also this may help you also http://www.phpfreaks.com/forums/index.php/topic,224436.0.html This code gets caled everytime when a user navigates to a diff page.
  2. EXPLAIN Select reg_users_ads.reg_users_ads_id, reg_users_ads.year, make, model, reg_users_ads.trim, reg_users_ads.price, reg_users_ads.exterior_color, reg_users_ads.transmission, reg_users_ads.mileage, zipcode FROM reg_users_ads, atrMakes, atrModels WHERE reg_users_ads.atrMakesID = '65' AND reg_users_ads.atrModelsID = '712' AND reg_users_ads.atrMakesID = atrMakes.atrMakesID AND reg_users_ads.atrModelsID = atrModels.atrModelsID AND reg_users_ads.zipcode IN ('75023','76888','76888','76888','78722') AND status = 'active'; the result being: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE atrMakes const PRIMARY PRIMARY 4 const 1 1 SIMPLE atrModels const PRIMARY PRIMARY 4 const 1 1 SIMPLE reg_users_ads ALL NULL NULL NULL NULL 18971 Using where
  3. I know what indexes are. However slightly confused as to what fields I will be placing indexes on ? Users can search for cars using make and model
  4. Hello, I am working on an automotive related site and am running into a wall. As the database is getting bigger, the searches seem to be getting slower and slower. You can see an example at http://alltherides.com/search.html Please give me some ideas and feedback as what I can do. I need the searches to be fast but am not that experienced in this domain. Any help will be greatly appreciated. Thanks
  5. amazing stuff !!! thanks a lot both of you. Now i really feel like a retard.
  6. thanks a lot man! Mind just doesnt work this early .
  7. rhodesa, thanks for your repky. I ran your code and i got : Array ( [10/31/08] => 1 [10/30/08] => 1 ) what I want to get is: Array ( [10/31/08] => 6 [10/30/08] => 2 ) so that I can graph the result
  8. hello, I have an array that contains the following data. 10/31/08*10/31/08*10/31/08*10/31/08*10/31/08*10/31/08*10/30/08/*10/30/08 for graphing purposes i need to get information like 10/31/08 = 6 visits 10/30/08 = 2 visits what would be the best way ? I am trying to build my own traffic graph thanks
  9. found it. its time(). thanks
  10. I guess I should have rephrased better. What about unix time stamp kinda like the SQL Now()
  11. yeah yeah......I was just testing if anyone was listening. hahahahaahhaha
  12. Surprisingly I am having a hard time finding this. please suggest. Thanks
  13. Would hate to write that code. Thanks
  14. Hello, I have a site in which each member has their own web page and listings. I need a way so that each member can track their own statistics on their pages. How would I get started ? Thanks
  15. Hahahahahahahaahahaha badass!!!! you my friend have saved me a lot of time !
  16. OK so I am trying to import a CVS file with a ton of column fields. while (file is not empty) { $firstname=$data[1]; $lastname=$data[2]; blah blah blah } My question is that is there an easier way to assign the CVS column values to a variable ? Any feed back will be appreciated
  17. It appears that our feed at http://alltherides.com/feed.xml is randomly being displayed in UTF-8 or ISO-8859-1 Whenever it is in UTF-8 it displays fine. WHen it is in ISO-8859-1 it shows up in just text form. Any help at all ????? We have used several headers like: header('Content-Type: application/rss+xml; charset=utf-8'); but nothing seems to be working
  18. <?xml version="1.0" encoding="ISO-8859-1"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" > <channel> <title>Latest Rides at AllTheRides.com</title> <atom:link href="http://alltherides.com/feed.xml" rel="self" type="application/rss+xml" /> <link>http://alltherides.com/feed.xml</link> <description>News covering All the Rides</description> <pubDate>Mon, 29 Sep 2008 03:44:37 -0500</pubDate> <generator>http://alltherides.com/</generator> <language>en</language> <item> <guid>http://www.alltherides.com/2006_Toyota_4Runner_for_sale_1189.html</guid> <title>2006 Toyota 4Runner</title> <description></description> <link>http://www.alltherides.com/2006_Toyota_4Runner_for_sale_1189.html</link> </item> <item> <guid>http://www.alltherides.com/2000_Ford_Expedition_for_sale_1190.html</guid> <title>2000 Ford Expedition</title> <description></description> <link>http://www.alltherides.com/2000_Ford_Expedition_for_sale_1190.html</link> </item> </channel> </rss>
  19. http://alltherides.com/feed.xml sometimes the page shows up as plain text and sometimes it shows up properly. please help.
  20. I also get other weird values.
  21. Hello, When my users input information in forms. Special characters get transformed. For example "and you don't have to do any" transforms to "and you don’t have to do any" how do i get the original text back ? Thanks
  22. *bump* anyone ?
  23. $pattern2="/^([A-Z]{3}|\d{3})[A-Z]{2}\d{2}([A-Z]{1}|\d{1})([\d{1}|X{1})([A-Z]+\d+|\d+[A-Z]+)\d{5}$/"; preg_match_all($pattern2, $content, $matches) still cannot find vins for example: YV1RS592572633234 was skipped in a block of text
  24. I tried both : $pattern1="/\A[A-HJ-NPR-Z\d]{11}\d{6}\z/"; $pattern2="([A-Z]{3}|\d{3})[A-Z]{2}\d{2}([A-Z]{1}|\d{1})([\d{1}|X{1})([A-Z]+\d+|\d+[A-Z]+)\d{5}"; pattern 1 was not able to find "1FMYU24E1WUD17422 " in a block of text. and pattern2 returned an error: Warning: preg_match_all() [function.preg-match-all]: Unknown modifier '['
  25. VIN should have only A-Z, 0-9 characters, but not I, O, or Q Last 6 characters of VIN should be a number VIN should be 17 characters long ummm should make an interesting regex. oh hey and thanks for your help in the other threads
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.