Modernvox Posted January 8, 2010 Share Posted January 8, 2010 I currently have a drop down form that allows users to select a state which display ads (Scraped from website). The problem is the form only works for the first use. Additional attempts will open a link from the previous process. In other words instead of displaying the new results it opens the last imported row from previous process? <?php $st = isset($_POST['submit']) ? $_POST['state'] : ''; $urls = array(); if ($st == "AL") { echo "Over 500 results detected! You may also search by city."; $urls = array("http://auburn.craigslist.org", "http://bham.craigslist.org"); } else if ($st == "AK") { $urls= array("http://anchorage.craigslist.org"); } else if ($st == "AZ") { $urls = array("http://anchorage.craigslist.org"); } foreach ($urls as $url) { $html = file_get_contents("$url/muc/"); preg_match_all('/<a href="([^"]+)">([^<]+)<\/a><font size="-1">([^"]+)<\/font>/s', $html,$posts,PREG_SET_ORDER); //echo "<pre>";print_r($posts); $i = 1; //set start point; $limit = 65; //set limit; foreach ($posts as $post) { //print $post[0]; //HTML $post[2] = str_ireplace($url,"",$post[2]); //remove domain echo "<a href=\"$url{$post[1]}\">{$post[2]}<font size=\"3\">{$post[3]}<br />"; print "<BR />\n"; if ($i == $limit) { break; } $i++; } } ?> Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/187759-form-selection-keeps-opening-a-link-on-second-attempt-and-onwards/ Share on other sites More sharing options...
Modernvox Posted January 9, 2010 Author Share Posted January 9, 2010 No goer's? Quote Link to comment https://forums.phpfreaks.com/topic/187759-form-selection-keeps-opening-a-link-on-second-attempt-and-onwards/#findComment-991472 Share on other sites More sharing options...
Modernvox Posted January 9, 2010 Author Share Posted January 9, 2010 Also it seems all elements i.e. images, text, etc... is linking to the last link returned?? Quote Link to comment https://forums.phpfreaks.com/topic/187759-form-selection-keeps-opening-a-link-on-second-attempt-and-onwards/#findComment-991475 Share on other sites More sharing options...
Zane Posted January 9, 2010 Share Posted January 9, 2010 Hi Zanus, Would you know why after I process a selection from my drop down form it only returns the values once. All subsequent selections link to the last result on previous selection? The page is here if you have a sec to troubleshoot. http://dezi9er.net16.net/page2.php Please don't PM me questions. As for your code... I don't see the form doing anything.. Quote Link to comment https://forums.phpfreaks.com/topic/187759-form-selection-keeps-opening-a-link-on-second-attempt-and-onwards/#findComment-991498 Share on other sites More sharing options...
Modernvox Posted January 9, 2010 Author Share Posted January 9, 2010 Ok..What is happening is the code is turning ALL elements on my entire page into a link to the last returned link from the code? Quote Link to comment https://forums.phpfreaks.com/topic/187759-form-selection-keeps-opening-a-link-on-second-attempt-and-onwards/#findComment-991518 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.