Jump to content

Form selection keeps opening a link on second attempt and onwards


Recommended Posts

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

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..

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.