Jump to content

Calling ALL Freaks "PHP Freaks that is :-)


Modernvox

Recommended Posts

$CL = "Craigslist";

 

I have my code all complete with one exception.

After I select a State from the drop down box the script scrapes the appropriate data from CL and displays it on the page. That's Great, right? Right!  But it also transforms all my buttons and images into a link which is the same link from the last results returned from the original request?

 

If you go to http://dezi9er.net16.net/search.php and just press submit the first attempt will return the results the way it is suppose to, But Now it turns everything into a link? click on the bouncer image or any of the buttons and it will take you to a CL listing.

 

This is crazy!  What is going on here?

Link to comment
Share on other sites

But it also transforms all my buttons and images into a link which is the same link from the last results returned from the original request?

 

Umm, If you're scraping links they'd become links after displaying them? What is your code? You're doing nothing but displaying a website to us without any relevant code.

Link to comment
Share on other sites

its making all the navigation etc link to the last search result... are you closing the anchor tag correctly (</a>)?

or is this last link overriding a variable which is storing the links for the navigation etc..?

you'll have to post your code.

Link to comment
Share on other sites

My Bad

 <?php
$st = isset($_POST['submit']) ? $_POST['state'] : '';

$urls = array();

if ($st == "AL") 
{

$urls = array("http://auburn.craigslist.org", "http://bham.craigslist.org");
}
else if ($st == "AK") 
{
$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 = 60; //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++; 
}

}
?>

Link to comment
Share on other sites

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.